Jump to content

centering 3 divs horizontally inside a div


Rifts

Recommended Posts

hey guys! I'm going a little crazy here

 

I have a div 960px wide, I'm trying to horizontally center three divs inside this 960px div. The two outside divs are 350px and the middle one is 10px. I cant seem to get them centered.

 

Here is what I'm doing:

 

html:

<div id="main">

		<div id="lefthalf">
		</div>

		<div id="middle">
		</div>

		<div id="righthalf">
		</div>

</div>

 

css:

#lefthalf {
float:left;
background-color: red;
width: 350px;
height: 400px;
border: 1px solid white;
}
#middle {
float:left;
background-color: blue;
width: 10px;
height: 400px;
border: 1px solid white;

}
#righthalf {
float:left;
background-color: green;
width: 350px;
height: 400px;
border: 1px solid white;
}

 

I cant figure out how to center them since they are floated left

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.