06-54-flexbox-column-order-teaser.html 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Flexbox columns: article teaser</title>
  6. <script src="js/html5shiv.min.js"></script>
  7. <style>
  8. body {
  9. font-family: Georgia, Times New Roman, serif;
  10. line-height: 1.5;
  11. max-width: 70em;
  12. margin: 0 auto;
  13. padding: 1em;
  14. }
  15. .article-teaser {
  16. display: -webkit-flex;
  17. display: -ms-flexbox;
  18. display: -webkit-box;
  19. display: -moz-box;
  20. display: flex;
  21. -webkit-flex-direction: column;
  22. -ms-flex-direction: column;
  23. -webkit-box-orient: vertical;
  24. -webkit-box-direction: normal;
  25. -moz-box-orient: vertical;
  26. -moz-box-direction: normal;
  27. flex-direction: column;
  28. max-width: 20em;
  29. padding: 1em;
  30. margin: 1em;
  31. border: 1px solid #ccc;
  32. }
  33. .article-teaser h2 {
  34. font-family: Avenir, SegoeUI, Franklin Gothic, sans-serif;
  35. font-size: 1.25em;
  36. margin: 0 0 .5em 0;
  37. }
  38. .article-teaser-text {
  39. margin: .5em 0;
  40. }
  41. .article-teaser-text p {
  42. margin: 0;
  43. }
  44. /**
  45. * 1. This is a fix for a peculiar sizing bug on images in flexbox columns
  46. * that appears to only happen in Chrome. The intrinsic dimensions of the
  47. * image are taken to mean the main-axis size, and thus the minimum size.
  48. * Setting an explicit min-height value counters this problem.
  49. */
  50. .article-teaser img {
  51. width: 100%;
  52. min-height: 0; /* [1] */
  53. -webkit-order: -1;
  54. -ms-flex-order: -1;
  55. order: -1;
  56. margin: 0 0 .5em 0;
  57. }
  58. .article-teaser-more {
  59. margin: .5em 0 0;
  60. }
  61. .article-teaser-more a {
  62. display: block;
  63. border-radius: .5em;
  64. background-color: #3372a0;
  65. font-family: Avenir, SegoeUI, Franklin Gothic, sans-serif;
  66. color: #fff;
  67. text-decoration: none;
  68. text-align: center;
  69. padding: .25em;
  70. }
  71. </style>
  72. </head>
  73. <body>
  74. <div class="article-teaser">
  75. <h2>The Dragon and other spaceships</h2>
  76. <div class="article-teaser-text">
  77. <p>There are actual spaceships,
  78. flying in space right now, probably. For example, there’s the International Space Station, which is
  79. a spaceship of sorts. Well, actually it’s a space station, which is even cooler!</p>
  80. </div>
  81. <img src="images/medium_spaceship.jpg" alt="The Dragon spaceship in orbit around Earth.">
  82. <p class="article-teaser-more">
  83. <a href="/spaceships">Read the whole Spaceship article</a>
  84. </p>
  85. </div>
  86. </body>
  87. </html>