_objects.layout.scss 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. /* ==========================================================================
  2. #LAYOUT
  3. ========================================================================== */
  4. /**
  5. * Grid-like layout system.
  6. *
  7. * The layout object provides us with a column-style layout system. This file
  8. * contains the basic structural elements, but classes should be complemented
  9. * with width utilities, for example:
  10. *
  11. * <div class="o-layout">
  12. * <div class="o-layout__item u-1/2">
  13. * </div>
  14. * <div class="o-layout__item u-1/2">
  15. * </div>
  16. * </div>
  17. *
  18. * The above will create a two-column structure in which each column will
  19. * fluidly fill half of the width of the parent. We can have more complex
  20. * systems:
  21. *
  22. * <div class="o-layout">
  23. * <div class="o-layout__item u-1/1 u-1/3@medium">
  24. * </div>
  25. * <div class="o-layout__item u-1/2 u-1/3@medium">
  26. * </div>
  27. * <div class="o-layout__item u-1/2 u-1/3@medium">
  28. * </div>
  29. * </div>
  30. *
  31. * The above will create a system in which the first item will be 100% width
  32. * until we enter our medium breakpoint, when it will become 33.333% width. The
  33. * second and third items will be 50% of their parent, until they also become
  34. * 33.333% width at the medium breakpoint.
  35. *
  36. * We can also manipulate entire layout systems by adding a series of modifiers
  37. * to the `.o-layout` block. For example:
  38. *
  39. * <div class="o-layout o-layout--reverse">
  40. *
  41. * This will reverse the displayed order of the system so that it runs in the
  42. * opposite order to our source, effectively flipping the system over.
  43. *
  44. * <div class="o-layout o-layout--[right|center]">
  45. *
  46. * This will cause the system to fill up from either the centre or the right
  47. * hand side. Default behaviour is to fill up the layout system from the left.
  48. *
  49. * There are plenty more options available to us: explore them below.
  50. */
  51. // By default we use the `font-size: 0;` trick to remove whitespace between
  52. // items. Set this to true in order to use a markup-based strategy like
  53. // commenting out whitespace or minifying HTML.
  54. $inuit-use-markup-fix: false !default;
  55. /* Default/mandatory classes
  56. ========================================================================== */
  57. /**
  58. * 1. Allows us to use the layout object on any type of element.
  59. * 2. We need to defensively reset any box-model properties.
  60. * 3. Use the negative margin trick for multi-row grids:
  61. * http://csswizardry.com/2011/08/building-better-grid-systems/
  62. */
  63. .o-layout {
  64. display: block; /* [1] */
  65. margin: 0; /* [2] */
  66. padding: 0; /* [2] */
  67. list-style: none; /* [1] */
  68. margin-left: -$inuit-global-spacing-unit; /* [3] */
  69. @if ($inuit-use-markup-fix == false) {
  70. font-size: 0;
  71. }
  72. }
  73. /**
  74. * 1. Required in order to combine fluid widths with fixed gutters.
  75. * 2. Allows us to manipulate grids vertically, with text-level properties,
  76. * etc.
  77. * 3. Default item alignment is with the tops of each other, like most
  78. * traditional grid/layout systems.
  79. * 4. By default, all layout items are full-width (mobile first).
  80. * 5. Gutters provided by left padding:
  81. * http://csswizardry.com/2011/08/building-better-grid-systems/
  82. * 6. Fallback for old IEs not supporting `rem` values.
  83. */
  84. .o-layout__item {
  85. box-sizing: border-box; /* [1] */
  86. display: inline-block; /* [2] */
  87. vertical-align: top; /* [3] */
  88. width: 100%; /* [4] */
  89. padding-left: $inuit-global-spacing-unit; /* [5] */
  90. @if ($inuit-use-markup-fix == false) {
  91. font-size: $inuit-global-font-size; /* [6] */
  92. font-size: 1rem;
  93. }
  94. }
  95. /* Gutter size modifiers
  96. ========================================================================== */
  97. .o-layout--flush {
  98. margin-left: 0;
  99. > .o-layout__item {
  100. padding-left: 0;
  101. }
  102. }
  103. .o-layout--tiny {
  104. margin-left: -$inuit-global-spacing-unit-tiny;
  105. > .o-layout__item {
  106. padding-left: $inuit-global-spacing-unit-tiny;
  107. }
  108. }
  109. .o-layout--small {
  110. margin-left: -$inuit-global-spacing-unit-small;
  111. > .o-layout__item {
  112. padding-left: $inuit-global-spacing-unit-small;
  113. }
  114. }
  115. .o-layout--large {
  116. margin-left: -$inuit-global-spacing-unit-large;
  117. > .o-layout__item {
  118. padding-left: $inuit-global-spacing-unit-large;
  119. }
  120. }
  121. .o-layout--huge {
  122. margin-left: -$inuit-global-spacing-unit-huge;
  123. > .o-layout__item {
  124. padding-left: $inuit-global-spacing-unit-huge;
  125. }
  126. }
  127. /* Vertical alignment modifiers
  128. ========================================================================== */
  129. /**
  130. * Align all grid items to the middles of each other.
  131. */
  132. .o-layout--middle {
  133. > .o-layout__item {
  134. vertical-align: middle;
  135. }
  136. }
  137. /**
  138. * Align all grid items to the bottoms of each other.
  139. */
  140. .o-layout--bottom {
  141. > .o-layout__item {
  142. vertical-align: bottom;
  143. }
  144. }
  145. /**
  146. * Stretch all grid items of each row to have an equal-height.
  147. * Please be aware that this modifier class doesn’t take any effect in IE9 and
  148. * below and other older browsers due to the lack of `display: flex` support.
  149. */
  150. .o-layout--stretch {
  151. display: flex;
  152. flex-wrap: wrap;
  153. > .o-layout__item {
  154. display: flex;
  155. }
  156. &.o-layout--center {
  157. justify-content: center;
  158. }
  159. &.o-layout--right {
  160. justify-content: flex-end;
  161. }
  162. &.o-layout--left {
  163. justify-content: flex-start;
  164. }
  165. }
  166. /* Fill order modifiers
  167. ========================================================================== */
  168. /**
  169. * Fill up the layout system from the centre.
  170. */
  171. .o-layout--center {
  172. text-align: center;
  173. > .o-layout__item {
  174. text-align: left;
  175. }
  176. }
  177. /**
  178. * Fill up the layout system from the right-hand side.
  179. */
  180. .o-layout--right {
  181. text-align: right;
  182. > .o-layout__item {
  183. text-align: left;
  184. }
  185. }
  186. /**
  187. * Fill up the layout system from the left-hand side. This will likely only be
  188. * needed when using in conjunction with `.o-layout--reverse`.
  189. */
  190. .o-layout--left {
  191. text-align: left;
  192. > .o-layout__item {
  193. text-align: left;
  194. }
  195. }
  196. /**
  197. * Reverse the rendered order of the grid system.
  198. */
  199. .o-layout--reverse {
  200. direction: rtl;
  201. > .o-layout__item {
  202. direction: ltr;
  203. }
  204. }
  205. /* Auto-widths modifier
  206. ========================================================================== */
  207. /**
  208. * Cause layout items to take up a non-explicit amount of width.
  209. */
  210. .o-layout--auto {
  211. > .o-layout__item {
  212. width: auto;
  213. }
  214. }