Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

center div between 2 divs

Posted on 2010-08-17
4
Medium Priority
?
267 Views
Last Modified: 2012-08-14
hello
i have 3 divs in a container. i seem to be having trouble getting the middle one (mailcenter) to center between the 2. i have attached my code and would be grateful if someone could tell me where i am going wrong. many thanks
css
==================================
#mailleft	{
	float: left;
	width: 150px;
	margin-top:180px;
	margin-left:17px;

	}
#mailright	{
	
float: right;
width: 150px;
margin-top:180px;

	
	}
.mailcenter	{

float: left;
width: 70%;
margin-top:180px;
 
	}
#container{
margin: 0 auto;   
text-align: left; 
width:97%;
		
		}

html
===============================================

<div id="container">
<div id="mailleft">
	<div id="accordion3">
    	<h2><a href="#">Mail</a></h2>
    	<div>First content</div>
    </div></div>
	<div class="mailcenter">
			<div id="accordion">
    		<h2><a href="#"><?php echo $_SESSION['kt_name_usr']; ?></a></h2>
    	<div>First content</div>
    </div></div>
	<div id="mailright"><div id="accordion2">
    	<h2><a href="#">Utilities</a></h2>
    	<div>First content</div>
    	<h2><a href="#">Tools</a></h2>
    	<div>Second content</div>
	</div></div>
</div>

Open in new window

0
Comment
Question by:peter_coop
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 13

Expert Comment

by:Onthrax
ID: 33459527
Looks good at first sight.. Is the container's width sufficient for all left/mid/right divs?
Try removing the width from the container and see what happens.

Also give the container a float left.
0
 

Author Comment

by:peter_coop
ID: 33459624
hi. if i remove the width totally throws the divs off. they seem to stack. also, other areas of the site rely on that container being that width. i have done a screenshot for your reference. thanks
divs.png
0
 
LVL 13

Accepted Solution

by:
Onthrax earned 1000 total points
ID: 33459823
If the container width is a requirement than please restore it. However your screenshot indicates that without the container width the order is as it should be, correct?
This means the middle container has a too large width to fit in the container so you should experiment with that a little.
0
 

Author Closing Comment

by:peter_coop
ID: 33459839
thank you
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question