How to put div next to centered div
If I have a div in the center of a page with the css
margin: 0px auto;
How do I get a div to the left of it(div 2) like in the image: http://i45.tinypic.com/34osvw3.png
that will never move from the left of it.
Floats are kinda like position:absolute in that floated elements are partially taken out of normal HTML doc flow.
Using width: 30% for all, I found that if one element is float: left and another is float: right, I could add an element margin: 0 auto AFTER the floated elements and it would ignore them and be centered. Putting the centered element before the floated ones, did not work.
so the main div in the middle would have the float also?
NO. Do NOT float div with margin: auto; that would take it partially out of normal HTML flow.
I saw this on a post nd tried it. My explanation is a guess,
but it seems logical. The position of the centered element AFTER the floated ones is important,
... add an element margin: 0 auto AFTER the floated elements and it would ignore them and be centered.
Hi there safinn,
try it like this...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="language" content="english">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>centered box with left appendage</title>
margin:6px auto 0;
Thanks a lot coothead! Worked great. Pretty simple, disappointed I didn't think of doing it like that.
Hi there safinn,
when you know the answer, then, of course, the question will no longer look difficult.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)