HTML CSS examples for CSS Layout:Position
Positioning with Top: -px
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <!--from ww w. ja v a 2 s . c om--> <body> <div id="div1" style="width: 1000px; height: 90px; background: red;"></div> <div id="div2" style="position: relative; top:-50px; width: 1000px; height: 90px; background: blue;"></div> <!--50 wasted pixels here--> <div id="div3" style="width: 1000px; background: green; height:90px; margin-top: -50px;"></div> </body> </html>