007-absolute.html 1.2 KB

12345678910111213141516171819
  1. <!doctype html>
  2. <html><head><meta charset="utf-8"><title>007 absolute</title>
  3. <style>
  4. html,body{margin:0;padding:0;background:#fff;color:#202020;font-family:sans-serif;font-size:13px}
  5. h1{font-size:20px;margin:10px 0 4px 10px}p{margin:0 0 10px 10px}
  6. .pane{float:left;width:440px;margin-left:10px}.label{background:#eee;padding:4px 6px;margin-bottom:4px}
  7. .stage{background:#fff;padding:8px;border:1px solid #999}
  8. .cover{width:200px;height:100px;background:#eee}
  9. .box{position:absolute;width:50px;height:40px}
  10. </style></head><body>
  11. <h1>007 &middot; absolute positioning</h1>
  12. <p>Both panes must show the red box at 20,10 and the blue box at 120,50.</p>
  13. <div class="pane"><div class="label">A: absolute</div><div class="stage">
  14. <div class="cover"><div class="box" style="left:20px;top:10px;background:#cc3333"></div><div class="box" style="left:120px;top:50px;background:#2244cc"></div></div>
  15. </div></div>
  16. <div class="pane"><div class="label">B: margins</div><div class="stage">
  17. <div class="cover" style="position:relative"><div class="box" style="position:static;margin-left:20px;margin-top:10px;background:#cc3333"></div><div class="box" style="position:static;margin-left:120px;margin-top:0;background:#2244cc"></div></div>
  18. </div></div>
  19. </body></html>