center div between 2 divs

Posted on 2010-08-17
Last Modified: 2012-08-14
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
#mailleft	{
	float: left;
	width: 150px;

#mailright	{
float: right;
width: 150px;

.mailcenter	{

float: left;
width: 70%;
margin: 0 auto;   
text-align: left; 


<div id="container">
<div id="mailleft">
	<div id="accordion3">
    	<h2><a href="#">Mail</a></h2>
    	<div>First content</div>
	<div class="mailcenter">
			<div id="accordion">
    		<h2><a href="#"><?php echo $_SESSION['kt_name_usr']; ?></a></h2>
    	<div>First content</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>

Open in new window

Question by:peter_coop
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
LVL 13

Expert Comment

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.

Author Comment

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
LVL 13

Accepted Solution

Onthrax earned 250 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.

Author Closing Comment

ID: 33459839
thank you

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Any Way to rotate banner ads from Commission Junction? 2 60
Make Float not to Wrap 15 66
transfer content to new site design 7 49
Sticking text to shapes in Raphael.js 6 41
This article discusses four methods for overlaying images in a container on a web page
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…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

751 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