Link to home
Start Free TrialLog in
Avatar of peter_coop
peter_coopFlag for United Kingdom of Great Britain and Northern Ireland

asked on

center div between 2 divs

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

Avatar of Onthrax
Onthrax
Flag of Netherlands image

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.
Avatar of peter_coop

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Onthrax
Onthrax
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thank you