08-17-responsive-news-grid.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Responsive news section example</title>
  6. <!-- the base styles and "housekeeping" styles are in here: -->
  7. <link rel="stylesheet" href="css/grid-base.css">
  8. <!-- Modernizr script to detect flexbox support,
  9. which also includes HTML5 shiv,
  10. to help older browsers understand styling
  11. on newer HTML5 elements: -->
  12. <script src="js/modernizr.min.js"></script>
  13. <!-- Meta viewport tag to enable correct viewport on mobile devices -->
  14. <meta name="viewport" content="width=device-width,initial-scale=1">
  15. <style>
  16. /* grid styling */
  17. .grid-b {
  18. display: -webkit-grid;
  19. display: grid;
  20. -webkit-grid-template-columns: 1fr;
  21. grid-template-columns: 1fr;
  22. -webkit-grid-template-areas: "hd" "st1" "." "st2" ".";
  23. grid-template-areas: "hd" "st1" "." "st2" ".";
  24. margin: 0 -.6875em;
  25. }
  26. @media only screen and (min-width: 37.5em) {
  27. .grid-b {
  28. -webkit-grid-template-columns: 1fr 1fr;
  29. grid-template-columns: 1fr 1fr;
  30. -webkit-grid-template-areas: "hd hd "
  31. "st1 ..."
  32. "... st2";
  33. grid-template-areas: "hd hd "
  34. "st1 ..."
  35. "... st2";
  36. }
  37. }
  38. @media only screen and (min-width: 55em) {
  39. .grid-b {
  40. -webkit-grid-template-columns: 1fr 1fr 1fr;
  41. grid-template-columns: 1fr 1fr 1fr;
  42. -webkit-grid-template-areas: "hd hd hd"
  43. "st1 .. st2"
  44. "st1 .. st2";
  45. grid-template-areas: "hd hd hd"
  46. "st1 .. st2"
  47. "st1 .. st2";
  48. }
  49. }
  50. @media only screen and (min-width: 70em) {
  51. .grid-b {
  52. -webkit-grid-template-columns: 20% 1fr 1fr 1fr;
  53. grid-template-columns: 20% 1fr 1fr 1fr;
  54. -webkit-grid-template-areas: "hd st1 . st2"
  55. "hd st1 . st2";
  56. grid-template-areas: "hd st1 . st2"
  57. "hd st1 . st2";
  58. }
  59. }
  60. .subcategory {
  61. margin-top: 1.5em;
  62. border-bottom: 1px solid #8e3339;
  63. }
  64. .grid-b .subcategory-header {
  65. padding: .6875em;
  66. -webkit-grid-area: hd;
  67. grid-area: hd;
  68. }
  69. .story {
  70. padding: .6875em;
  71. margin: 0 .6875em 1.375em;
  72. background-color: #eee;
  73. }
  74. .grid-b .story:nth-of-type(1) {
  75. -webkit-grid-area: st1;
  76. grid-area: st1;
  77. }
  78. .grid-b .story:nth-of-type(2) {
  79. -webkit-grid-area: st2;
  80. grid-area: st2;
  81. }
  82. .story-featured {
  83. -webkit-grid-area: a;
  84. grid-area: a;
  85. }
  86. /* content styling */
  87. .subcategory {
  88. margin-top: 1.5em;
  89. border-bottom: 1px solid #8e3339;
  90. }
  91. .story {
  92. padding: .6875em;
  93. background-color: #eee;
  94. }
  95. .story img {
  96. width: 100%;
  97. }
  98. .ad {
  99. padding: .6875em;
  100. margin: 0 .6875em 1.375em;
  101. display: -webkit-flex;
  102. display: -ms-flexbox;
  103. display: flex;
  104. background-color: #8e3339;
  105. color: #fff;
  106. }
  107. .ad h3 {
  108. margin: auto;
  109. }
  110. .ad h3 a {
  111. color: inherit;
  112. }
  113. </style>
  114. </head>
  115. <body>
  116. <header class="masthead">
  117. <div class="wrapper">
  118. <h1>Important News</h1>
  119. </div>
  120. </header>
  121. <nav role="navigation" class="navbar">
  122. <div class="wrapper">
  123. <ul class="navlist">
  124. <li><a href="#">Home</a></li>
  125. <li><a href="#">World</a></li>
  126. <li><a href="#">Local</a></li>
  127. <li><a href="#">Sports</a></li>
  128. </ul>
  129. </div>
  130. </nav>
  131. <main class="wrapper">
  132. <section class="subcategory">
  133. <div class="grid-b">
  134. <header class="subcategory-header">
  135. <h2>Dolor sit amet</h2>
  136. </header>
  137. <article class="story">
  138. <img src="http://placehold.it/600x300" alt="Dummy image">
  139. <h3><a href="#">Ut sit amet mi massa</a></h3>
  140. <p>Neque magnam vero obcaecati facere nobis sint dolore accusamus vitae consequuntur ad necessitatibus, laborum molestiae.</p>
  141. </article>
  142. <article class="story">
  143. <img src="http://placehold.it/600x300" alt="Dummy image">
  144. <h3><a href="#">Animi, explicabo, ipsum</a></h3>
  145. <p>Neque magnam vero obcaecati facere nobis sint dolore accusamus vitae consequuntur ad necessitatibus, laborum molestiae.</p>
  146. </article>
  147. <div class="ad">
  148. <h3><a href="#">Buy more stuff!</a></h3>
  149. </div>
  150. <div class="ad">
  151. <h3><a href="#">Buy other stuff!</a></h3>
  152. </div>
  153. </div>
  154. </section>
  155. </main>
  156. </body>
  157. </html>