07-XX-float-columns-grid-wrapping-inline.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Float layout plus wrapping rows using inline-block</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. /* grid styling */
  13. .row {
  14. margin: 0 -.6875em;
  15. padding: 0;
  16. list-style: none;
  17. }
  18. .row:after {
  19. content: '';
  20. display: block;
  21. clear: both;
  22. }
  23. .row-quartet > * {
  24. width: 25%;
  25. }
  26. .row-trio > * {
  27. width: 33.3333%;
  28. }
  29. .col {
  30. float: left;
  31. -moz-box-sizing: border-box;
  32. box-sizing: border-box;
  33. margin: 0;
  34. padding: 0 .6875em 1.375em;
  35. }
  36. .col:last-child {
  37. float: right;
  38. }
  39. .row-wrapping {
  40. font-size: 0;
  41. margin: 0 -11px;
  42. margin: 0 -.6875rem;
  43. }
  44. .row-wrapping > * {
  45. float: none;
  46. vertical-align: top;
  47. display: inline-block;
  48. font-size: 16px;
  49. font-size: 1rem;
  50. }
  51. /* content styling */
  52. .subcategory {
  53. margin-top: 1.5em;
  54. border-bottom: 1px solid #8e3339;
  55. }
  56. .subcategory-featured {
  57. width: 50%;
  58. }
  59. .subcategory-content {
  60. width: 80%;
  61. }
  62. .subcategory-header {
  63. width: 20%;
  64. }
  65. .story {
  66. padding: .6875em;
  67. background-color: #eee;
  68. }
  69. .story + .story {
  70. margin-top: 1.375em;
  71. }
  72. .story img {
  73. width: 100%;
  74. }
  75. </style>
  76. </head>
  77. <body>
  78. <header class="masthead">
  79. <div class="wrapper">
  80. <h1>Important News</h1>
  81. </div>
  82. </header>
  83. <nav role="navigation" class="navbar">
  84. <div class="wrapper">
  85. <ul class="navlist">
  86. <li><a href="#">Home</a></li>
  87. <li><a href="#">World</a></li>
  88. <li><a href="#">Local</a></li>
  89. <li><a href="#">Sports</a></li>
  90. </ul>
  91. </div>
  92. </nav>
  93. <main class="wrapper">
  94. <section class="subcategory">
  95. <div class="row">
  96. <header class="col subcategory-header">
  97. <h2>Lorem ipsum</h2>
  98. </header>
  99. <div class="col subcategory-content">
  100. <div class="row row-quartet">
  101. <div class="col subcategory-featured">
  102. <article class="story">
  103. <img src="http://placehold.it/600x300" alt="Dummy image">
  104. <h3><a href="#">Cras suscipit nec leo id.</a></h3>
  105. <p>Autem repudiandae aliquid tempora quos reprehenderit architecto, sequi repellat.</p>
  106. </article>
  107. </div>
  108. <div class="col">
  109. <article class="story">
  110. <img src="http://placehold.it/600x300" alt="Dummy image">
  111. <h3><a href="#">Perferendis, ipsam!</a></h3>
  112. <p>Neque magnam vero obcaecati facere nobis sint dolore accusamus vitae consequuntur ad necessitatibus, laborum molestiae.</p>
  113. </article>
  114. </div>
  115. <div class="col">
  116. <article class="story">
  117. <img src="http://placehold.it/600x300" alt="Dummy image">
  118. <h3><a href="#">Curabitur mattis purus nec velit.</a></h3>
  119. <p>Neque magnam vero obcaecati facere nobis sint dolore accusamus vitae consequuntur ad necessitatibus, laborum molestiae.</p>
  120. </article>
  121. </div>
  122. </div>
  123. <ul class="row row-quartet row-wrapping">
  124. <li class="col">
  125. <div class="story">
  126. <h3><a href="#">Perferendis, ipsam! Dolor sit amet consectetur</a></h3>
  127. </div>
  128. </li>
  129. <li class="col">
  130. <div class="story">
  131. <h3><a href="#">Aliquam mattis eros id posuere.</a></h3>
  132. </div>
  133. </li>
  134. <li class="col">
  135. <div class="story">
  136. <h3><a href="#">Proin leo felis, semper nec</a></h3>
  137. </div>
  138. </li>
  139. <li class="col">
  140. <div class="story">
  141. <h3><a href="#">Aliquam vitae risus tortor. Sed!</a></h3>
  142. </div>
  143. </li>
  144. <li class="col">
  145. <div class="story">
  146. <h3><a href="#">Perferendis, ipsam!</a></h3>
  147. </div>
  148. </li>
  149. <li class="col">
  150. <div class="story">
  151. <h3><a href="#">Aliquam mattis eros id posuere.</a></h3>
  152. </div>
  153. </li>
  154. <li class="col">
  155. <div class="story">
  156. <h3><a href="#">Proin leo felis, semper nec</a></h3>
  157. </div>
  158. </li>
  159. <li class="col">
  160. <div class="story">
  161. <h3><a href="#">Aliquam vitae risus tortor. Sed!</a></h3>
  162. </div>
  163. </li>
  164. </div>
  165. </div>
  166. </div>
  167. </section>
  168. <section class="subcategory">
  169. <div class="row">
  170. <header class="col subcategory-header">
  171. <h2>Dolor sit amet</h2>
  172. </header>
  173. <div class="col subcategory-content">
  174. <div class="row row-trio">
  175. <div class="col">
  176. <article class="story">
  177. <img src="http://placehold.it/600x300" alt="Dummy image">
  178. <h3><a href="#">Ut sit amet mi massa</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. <h3><a href="#">Nunc mollis sit amet nunc</a></h3>
  185. <p>Neque magnam vero obcaecati facere nobis sint dolore accusamus vitae consequuntur ad necessitatibus, laborum molestiae.</p>
  186. </article>
  187. <article class="story">
  188. <h3><a href="#">Duis sed ante enim. Cras</a></h3>
  189. <p>Neque magnam vero obcaecati facere nobis sint dolore accusamus vitae consequuntur ad necessitatibus, laborum molestiae.</p>
  190. </article>
  191. </div>
  192. <div class="col">
  193. <article class="story">
  194. <img src="http://placehold.it/600x300" alt="Dummy image">
  195. <h3><a href="#">Animi, explicabo, ipsum</a></h3>
  196. <p>Neque magnam vero obcaecati facere nobis sint dolore accusamus vitae consequuntur ad necessitatibus, laborum molestiae.</p>
  197. </article>
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. </section>
  203. </main>
  204. </body>
  205. </html>