018-relative.html 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>018 relative</title>
  6. <style>
  7. html, body { margin: 0; padding: 0; background: #ffffff; color: #202020; }
  8. body { font-family: sans-serif; font-size: 13px; }
  9. h1 { font-size: 20px; margin: 10px 0 4px 10px; }
  10. p { margin: 0 0 10px 10px; }
  11. .pane { float: left; width: 440px; margin-left: 10px; }
  12. .label { background: #eeeeee; padding: 4px 6px; margin-bottom: 4px; }
  13. .stage { background: #ffffff; padding: 8px; border: 1px solid #999999; }
  14. .red { width: 120px; height: 30px; background: #cc3333; }
  15. .after { background: #333333; color: #ffffff; height: 24px; padding-left: 4px; }
  16. </style>
  17. </head>
  18. <body>
  19. <h1>018 &middot; position: relative</h1>
  20. <p>The red box and the following bar must be in the same place in both panes.</p>
  21. <div class="pane">
  22. <div class="label">A: relative left/top</div>
  23. <div class="stage">
  24. <div class="red" style="position: relative; left: 40px; top: 20px"></div>
  25. <div class="after">after</div>
  26. </div>
  27. </div>
  28. <div class="pane">
  29. <div class="label">B: margins</div>
  30. <div class="stage">
  31. <div class="red" style="margin-left: 40px; margin-top: 20px; margin-bottom: -20px"></div>
  32. <div class="after">after</div>
  33. </div>
  34. </div>
  35. </body>
  36. </html>