07-25-grid-layout-order.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Grid layout using the auto algorithm and explicit order</title>
  6. <!-- the base styles and "housekeeping" styles are in here: -->
  7. <link rel="stylesheet" href="css/grid-base.css">
  8. <!-- the HTML5 shiv, to help older browsers understand styling
  9. on newer HTML5 elements: -->
  10. <script src="js/html5shiv.min.js"></script>
  11. <style>
  12. /* content styling */
  13. .grid-a {
  14. display: -webkit-grid;
  15. display: grid;
  16. -webkit-grid-template-rows: auto auto auto;
  17. grid-template-rows: auto auto auto;
  18. -webkit-grid-template-columns: repeat(5, 1fr);
  19. grid-template-columns: repeat(5, 1fr);
  20. margin: 0 -.6875em;
  21. }
  22. .subcategory {
  23. margin-top: 1.5em;
  24. border-bottom: 1px solid #8e3339;
  25. }
  26. .subcategory-header {
  27. padding: .6875em;
  28. -webkit-grid-row: 1/-1;
  29. grid-row: 1/-1;
  30. }
  31. .story:nth-of-type(2),
  32. .story:nth-of-type(3) {
  33. -webkit-order: -2;
  34. order: -2;
  35. }
  36. .story-featured {
  37. -webkit-order: -1;
  38. order: -1;
  39. -webkit-grid-column: span 2;
  40. grid-column: span 2;
  41. }
  42. .story {
  43. padding: .6875em;
  44. margin: 0 .6875em 1.375em;
  45. background-color: #eee;
  46. }
  47. .story img {
  48. /* width: 100%; */
  49. max-width: 100%;
  50. }
  51. </style>
  52. </head>
  53. <body>
  54. <header class="masthead">
  55. <div class="wrapper">
  56. <h1>Important News</h1>
  57. </div>
  58. </header>
  59. <nav role="navigation" class="navbar">
  60. <div class="wrapper">
  61. <ul class="navlist">
  62. <li><a href="#">Home</a></li>
  63. <li><a href="#">World</a></li>
  64. <li><a href="#">Local</a></li>
  65. <li><a href="#">Sports</a></li>
  66. </ul>
  67. </div>
  68. </nav>
  69. <main class="wrapper">
  70. <section class="subcategory subcategory-a">
  71. <div class="grid-a">
  72. <header class="subcategory-header">
  73. <h2>Lorem ipsum</h2>
  74. </header>
  75. <article class="story story-featured">
  76. <img src="http://placehold.it/600x300" alt="Dummy image">
  77. <h3><a href="#">Cras suscipit nec leo id.</a></h3>
  78. <p>Autem repudiandae aliquid tempora quos reprehenderit architecto, sequi repellat.</p>
  79. </article>
  80. <article class="story">
  81. <img src="http://placehold.it/600x300" alt="Dummy image">
  82. <h3><a href="#">Perferendis, ipsam!</a></h3>
  83. <p>Neque magnam vero obcaecati facere nobis sint dolore accusamus vitae consequuntur ad necessitatibus, laborum molestiae.</p>
  84. </article>
  85. <article class="story">
  86. <img src="http://placehold.it/600x300" alt="Dummy image">
  87. <h3><a href="#">Curabitur mattis purus nec velit.</a></h3>
  88. <p>Neque magnam vero obcaecati facere nobis sint dolore accusamus vitae consequuntur ad necessitatibus, laborum molestiae.</p>
  89. </article>
  90. <article class="story">
  91. <h3><a href="#">Perferendis, ipsam!</a></h3>
  92. </article>
  93. <article class="story">
  94. <h3><a href="#">Aliquam mattis eros id posuere.</a></h3>
  95. </article>
  96. <article class="story">
  97. <h3><a href="#">Proin leo felis, semper nec</a></h3>
  98. </article>
  99. <article class="story">
  100. <h3><a href="#">Aliquam vitae risus tortor. Sed!</a></h3>
  101. </article>
  102. <article class="story">
  103. <h3><a href="#">Perferendis, ipsam!</a></h3>
  104. </article>
  105. <article class="story">
  106. <h3><a href="#">Aliquam mattis eros id posuere.</a></h3>
  107. </article>
  108. <article class="story">
  109. <h3><a href="#">Proin leo felis, semper nec</a></h3>
  110. </article>
  111. <article class="story">
  112. <h3><a href="#">Aliquam vitae risus tortor. Sed!</a></h3>
  113. </article>
  114. </div>
  115. </section>
  116. </main>
  117. </body>
  118. </html>