08-05-responsive-news.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Responsive news section example</title>
  6. <!-- Modernizr script to detect flexbox support,
  7. which also includes HTML5 shiv,
  8. to help older browsers understand styling
  9. on newer HTML5 elements: -->
  10. <script src="js/modernizr.min.js"></script>
  11. <!-- the base styles and "housekeeping" styles are in here: -->
  12. <link rel="stylesheet" href="css/grid-base.css">
  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. /**
  18. * [1] Remove list-style and default padding, in case any
  19. * columns are actually <li> items.
  20. * [2] Negative margin equal to 1/2 gutter width.
  21. */
  22. .row {
  23. list-style: none; /* [1] */
  24. padding: 0; /* [1] */
  25. margin: 0 -.6875em; /* [2] */
  26. }
  27. /**
  28. * Make sure rows contain floats.
  29. */
  30. .row:after {
  31. content: '';
  32. display: block;
  33. clear: both;
  34. }
  35. /**
  36. * [1] Set font-size to 0 to counteract the white-space issue with
  37. * inline-block children.
  38. * [2] Set the negative margin in px as a "good-enough" fallback for IE8 (see 3)
  39. * [3] Set the negative margin in rems instead of ems as the font-size is 0.
  40. */
  41. .row-wrapping {
  42. font-size: 0; /* [1] */
  43. margin: 0 -11px; /* [2] */
  44. margin: 0 -.6875rem; /* [3] */
  45. }
  46. /**
  47. * Children of wrapping rows are inline blocks.
  48. * [1] Set the font-size in as a fallback for browsers without rem support
  49. * e.g. IE8. (see 2)
  50. * [2] Set the font size using rems since font-size on parent is 0.
  51. */
  52. .row-wrapping > .col {
  53. float: none;
  54. vertical-align: top;
  55. display: inline-block;
  56. font-size: 16px;
  57. font-size: 1rem;
  58. }
  59. /**
  60. * [1] Set columns to float/100% width by default, despite not needing to for
  61. * for single-column layouts. That way, we don't need to decide at which
  62. * breakpoint the column starts floating.
  63. */
  64. .col {
  65. -moz-box-sizing: border-box;
  66. box-sizing: border-box;
  67. padding: 0 .6875em 1.375em;
  68. float: left; /* [1] */
  69. width: 100%; /* [1] */
  70. }
  71. /**
  72. * If flexbox wrapping is supported, it will be automatically taken care of
  73. * at the various breakpoints.
  74. */
  75. .flexwrap .row {
  76. display: -webkit-flex;
  77. display: -ms-flexbox;
  78. display: flex;
  79. -webkit-flex-wrap: wrap;
  80. -ms-flex-wrap: wrap;
  81. flex-wrap: wrap;
  82. }
  83. /**
  84. * Set columns as flexbox column containers, to enable equal height columns
  85. * on wider screens later, if wrapping is supported.
  86. */
  87. .flexwrap .col {
  88. display: -webkit-flex;
  89. display: -ms-flexbox;
  90. display: flex;
  91. -webkit-flex-direction: column;
  92. -ms-flex-direction: column;
  93. flex-direction: column;
  94. }
  95. .flexwrap .col > * {
  96. -webkit-flex: 1;
  97. -ms-flex: 1 0 auto;
  98. flex: 1;
  99. }
  100. @media only screen and (min-width: 35em) {
  101. .row-quartet > * {
  102. width: 50%;
  103. }
  104. .subcategory-featured {
  105. width: 100%;
  106. }
  107. }
  108. @media only screen and (min-width: 50em) {
  109. .row-quartet > * {
  110. width: 25%;
  111. }
  112. .subcategory-featured {
  113. width: 50%;
  114. }
  115. }
  116. @media only screen and (min-width: 70em) {
  117. .subcategory-header {
  118. width: 20%;
  119. }
  120. .subcategory-content {
  121. width: 80%;
  122. }
  123. }
  124. .col:last-child {
  125. float: right;
  126. }
  127. /* content styling */
  128. .subcategory {
  129. margin-top: 1.5em;
  130. border-bottom: 1px solid #8e3339;
  131. }
  132. .story {
  133. padding: .6875em;
  134. background-color: #eee;
  135. }
  136. .story + .story {
  137. margin-top: 1.375em;
  138. }
  139. .story img {
  140. width: 100%;
  141. }
  142. </style>
  143. </head>
  144. <body>
  145. <header class="masthead">
  146. <div class="wrapper">
  147. <h1>Important News</h1>
  148. </div>
  149. </header>
  150. <nav role="navigation" class="navbar">
  151. <div class="wrapper">
  152. <ul class="navlist">
  153. <li><a href="#">Home</a></li>
  154. <li><a href="#">World</a></li>
  155. <li><a href="#">Local</a></li>
  156. <li><a href="#">Sports</a></li>
  157. </ul>
  158. </div>
  159. </nav>
  160. <main class="wrapper">
  161. <section class="subcategory">
  162. <div class="row">
  163. <header class="col subcategory-header">
  164. <h2>Lorem ipsum</h2>
  165. </header>
  166. <div class="col subcategory-content">
  167. <div class="row row-quartet">
  168. <div class="col subcategory-featured">
  169. <article class="story">
  170. <img src="http://placehold.it/600x300" alt="Dummy image">
  171. <h3><a href="#">Cras suscipit nec leo id.</a></h3>
  172. <p>Autem repudiandae aliquid tempora quos reprehenderit architecto, sequi repellat.</p>
  173. </article>
  174. </div>
  175. <div class="col">
  176. <article class="story">
  177. <img src="http://placehold.it/600x300" alt="Dummy image">
  178. <h3><a href="#">Perferendis, ipsam!</a></h3>
  179. <p>Neque magnam vero obcaecati facere nobis sint dolore accusamus vitae consequuntur ad necessitatibus, laborum molestiae.</p>
  180. </article>
  181. </div>
  182. <div class="col">
  183. <article class="story">
  184. <img src="http://placehold.it/600x300" alt="Dummy image">
  185. <h3><a href="#">Curabitur mattis purus nec velit.</a></h3>
  186. <p>Neque magnam vero obcaecati facere nobis sint dolore accusamus vitae consequuntur ad necessitatibus, laborum molestiae.</p>
  187. </article>
  188. </div>
  189. </div>
  190. <ul class="row row-quartet row-wrapping">
  191. <li class="col">
  192. <div class="story">
  193. <h3><a href="#">Perferendis, ipsam! Dolor sit amet consectetur</a></h3>
  194. </div>
  195. </li>
  196. <li class="col">
  197. <div class="story">
  198. <h3><a href="#">Aliquam mattis eros id posuere.</a></h3>
  199. </div>
  200. </li>
  201. <li class="col">
  202. <div class="story">
  203. <h3><a href="#">Proin leo felis, semper nec</a></h3>
  204. </div>
  205. </li>
  206. <li class="col">
  207. <div class="story">
  208. <h3><a href="#">Aliquam vitae risus tortor. Sed!</a></h3>
  209. </div>
  210. </li>
  211. <li class="col">
  212. <div class="story">
  213. <h3><a href="#">Perferendis, ipsam!</a></h3>
  214. </div>
  215. </li>
  216. <li class="col">
  217. <div class="story">
  218. <h3><a href="#">Aliquam mattis eros id posuere.</a></h3>
  219. </div>
  220. </li>
  221. <li class="col">
  222. <div class="story">
  223. <h3><a href="#">Proin leo felis, semper nec</a></h3>
  224. </div>
  225. </li>
  226. <li class="col">
  227. <div class="story">
  228. <h3><a href="#">Aliquam vitae risus tortor. Sed!</a></h3>
  229. </div>
  230. </li>
  231. </ul>
  232. </div>
  233. </div>
  234. </section>
  235. </main>
  236. </body>
  237. </html>