07-XX-grid-layout-minmax.html 3.7 KB

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