Solved

center div between 2 divs

Posted on 2010-08-17
4
261 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
WordPress Themes 10 34
Message not shown 5 33
webpage layout breaks when expanding bootstrap collapse component 8 14
CSS z-index issue 3 22
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

867 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now