Solved

center div between 2 divs

Posted on 2010-08-17
4
262 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
  • 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 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.
0
 

Author Closing Comment

by:peter_coop
ID: 33459839
thank you
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
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…

777 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