022-flex-align.html 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>022 flex alignment</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. .cover { background: #eeeeee; width: 360px; height: 100px; }
  15. .item { width: 60px; }
  16. .after { background: #333333; color: #ffffff; height: 24px; margin-top: 8px; padding-left: 4px; }
  17. </style>
  18. </head>
  19. <body>
  20. <h1>022 &middot; flex alignment</h1>
  21. <p>Three 60px items must be space-between and vertically centred in both panes.</p>
  22. <div class="pane">
  23. <div class="label">A: justify-content / align-items</div>
  24. <div class="stage">
  25. <div class="cover" style="display: flex; justify-content: space-between; align-items: center">
  26. <div class="item" style="height: 40px; background: #cc2222"></div>
  27. <div class="item" style="height: 60px; background: #22aa44"></div>
  28. <div class="item" style="height: 80px; background: #2244cc"></div>
  29. </div>
  30. <div class="after">after</div>
  31. </div>
  32. </div>
  33. <div class="pane">
  34. <div class="label">B: absolute reference</div>
  35. <div class="stage">
  36. <div class="cover">
  37. <div class="item" style="position: absolute; left: 0; top: 30px; height: 40px; background: #cc2222"></div>
  38. <div class="item" style="position: absolute; left: 150px; top: 20px; height: 60px; background: #22aa44"></div>
  39. <div class="item" style="position: absolute; left: 300px; top: 10px; height: 80px; background: #2244cc"></div>
  40. </div>
  41. <div class="after">after</div>
  42. </div>
  43. </div>
  44. </body>
  45. </html>