HTML CSS examples for CSS Layout:Absolute Position
Make Absolute positioning inside relative positioning
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> #box1, #box2 {<!--from ww w . j av a 2s . c om--> width:100px; height:100px; color:Chartreuse; text-align:center; line-height:100px; } #box1 { background:green; position:relative; } #box2 { background:blue; } #inner1, #inner2 { width:51px; height:51px; top:0; right:0; position:absolute; background:black; opacity:0.6; color:yellow; text-align:center; line-height:51px; } </style> </head> <body> <div id="box1"> 1 <div id="inner1"> 1 </div> </div> <div id="box2"> 2 <div id="inner2"> 2 </div> </div> </body> </html>