HTML CSS examples for CSS Layout:Relative Position
Position absolute but relative to parent
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> .childrens<!--from ww w. j av a 2 s.com--> { position:absolute; background-color:Chartreuse; height:201px; border:3px solid yellow; } #child1 { right:0; top:21px; } #child2 { float:left; top:41px; } #child3 { top:71px; left:51% } #mainall { background-color:blue; height:151px; overflow:scroll } </style> </head> <body> <div id="mainall"> <div id="child1" class="childrens"> Lorem ip </div> <div id="child2" class="childrens"> Lorem ip </div> <div id="child3" class="childrens"> Lorem ip </div> </div> </body> </html>