Solved

center div between 2 divs

Posted on 2010-08-17
4
260 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
thank you
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

763 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

15 Experts available now in Live!

Get 1:1 Help Now