If you want to position divs next to each other like you're trying to do, use float
:
#left {
float: left;
width: 100px;
}
#right {
float: right;
width: 50px;
}
.clear {
clear: both;
}
I also added a .clear class: make sure you clear the floats so any content that follows is positioned underneath these two floats:
<div id="left">left content</div>
<div id="right">right content</div>
<div class="clear"></div>
Also, you can't use left/right/top/bottom
on relatively position elements. Use them on an absolute positioned element instead by placing the position:absolute
element within a position:relative
element. In this case you shouldn't be using this though.
And try to avoid using margin
to "push" an element to a certain spot. Now you're adding a negative top-margin to get it to go up. But if you're doing that it usually means you should try another layout setup.