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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.