omnix
omnix

Reputation: 1899

How to spread these divs out evenly?

I want the boxes to spread out just like this:

alt text

exactly 218 pixels across from each other.

I tried to margin both of them together but I can't get it perfect!

.box1, .box2 { margin: 0 20px }

Is there a better way to get this right?

I forgot to mention, there already floated.

Upvotes: 0

Views: 978

Answers (3)

brett
brett

Reputation: 191

Float the divs left and right, make the width of the container div 218 pixels larger than needed. But then you run into problems if the left and right box are dynamically sized.

Or float them both left, and put a margin-right on the first box like the above post.

Upvotes: 0

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114377

.box1, .box2 { float:left }
.box2 { margin-left:218px }

Upvotes: 0

simshaun
simshaun

Reputation: 21466

Why not just do a margin-right: 218px; on .box1? Am I missing something?

Upvotes: 1

Related Questions