1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
<!DOCTYPE html> <style> #container { text-align: center; width: 100px; } #relpos { position: relative; background: red; } #abspos { position: absolute; left: 0; top: 0; width: 50px; height: 50px; background: green; } </style> <body> <div id="container"> <span id="relpos">x <span id="abspos"></span> </span> </div> </body>