<div id="foo">
<div></div>
<div id="bar"></div>
<div></div>
</div>
How do you get top of "bar" to be positioned -5px relative to its original position and also removed from the normal flow?
#bar {
position: relative;
top: -5px;
}
Doesn't work since "bar" is not removed from normal flow
#foo {
position: relative;
}
#bar {
position: absolute;
top: -5px;
}
Doesn't work since top of "bar" is placed -5px relative to "foo"
Try
#bar {
position: absolute;
margin-top: -5px;
}
See this live example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With