You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

176 lines
8.3 KiB

4 years ago
  1. +++
  2. title = "Grid"
  3. description = "Display a responsive grid with cells."
  4. categories = ["experience"]
  5. tags = []
  6. html_attributes = ["class"]
  7. custom_attributes = []
  8. snippets_used = ["cell", "card", "button"]
  9. [[copyright]]
  10. owner = "Josh Habdas"
  11. date = "2019"
  12. license = "agpl-3.0-or-later"
  13. +++
  14. Containing three [Cell](../cell) of equal size:
  15. {{< highlight html "linenos=inline" >}}
  16. {{</* hackcss-grid >}}
  17. {{< hackcss-cell class="-4of12" text="4" />}}
  18. {{< hackcss-cell class="-4of12" text="4" />}}
  19. {{< hackcss-cell class="-4of12" text="4" />}}
  20. {{< /hackcss-grid */>}}
  21. {{< /highlight >}}
  22. {{< hackcss-grid class="unset-margin" >}}
  23. {{< hackcss-cell class="-4of12" text="4" />}}
  24. {{< hackcss-cell class="-4of12" text="4" />}}
  25. {{< hackcss-cell class="-4of12" text="4" />}}
  26. {{< /hackcss-grid >}}
  27. With two columns of odd size:
  28. ```html
  29. {{</* hackcss-grid >}}
  30. {{< hackcss-cell class="-4of12" text="4" />}}
  31. {{< hackcss-cell class="-8of12" text="8" />}}
  32. {{< /hackcss-grid */>}}
  33. ```
  34. {{< hackcss-grid class="example" >}}
  35. {{< hackcss-cell class="-4of12" text="4" />}}
  36. {{< hackcss-cell class="-8of12" text="8" />}}
  37. {{< /hackcss-grid >}}
  38. With 12 columns:
  39. ```html
  40. {{</* hackcss-grid >}}
  41. {{< hackcss-cell class="-1of12" text="1" />}}
  42. {{< hackcss-cell class="-1of12" text="1" />}}
  43. {{< hackcss-cell class="-1of12" text="1" />}}
  44. {{< hackcss-cell class="-1of12" text="1" />}}
  45. {{< hackcss-cell class="-1of12" text="1" />}}
  46. {{< hackcss-cell class="-1of12" text="1" />}}
  47. {{< hackcss-cell class="-1of12" text="1" />}}
  48. {{< hackcss-cell class="-1of12" text="1" />}}
  49. {{< hackcss-cell class="-1of12" text="1" />}}
  50. {{< hackcss-cell class="-1of12" text="1" />}}
  51. {{< hackcss-cell class="-1of12" text="1" />}}
  52. {{< hackcss-cell class="-1of12" text="1" />}}
  53. {{< /hackcss-grid */>}}
  54. ```
  55. {{< hackcss-grid >}}
  56. {{< hackcss-cell class="-1of12" text="1" />}}
  57. {{< hackcss-cell class="-1of12" text="1" />}}
  58. {{< hackcss-cell class="-1of12" text="1" />}}
  59. {{< hackcss-cell class="-1of12" text="1" />}}
  60. {{< hackcss-cell class="-1of12" text="1" />}}
  61. {{< hackcss-cell class="-1of12" text="1" />}}
  62. {{< hackcss-cell class="-1of12" text="1" />}}
  63. {{< hackcss-cell class="-1of12" text="1" />}}
  64. {{< hackcss-cell class="-1of12" text="1" />}}
  65. {{< hackcss-cell class="-1of12" text="1" />}}
  66. {{< hackcss-cell class="-1of12" text="1" />}}
  67. {{< hackcss-cell class="-1of12" text="1" />}}
  68. {{< /hackcss-grid >}}
  69. Enclosing [Cards](../card/) with various [Buttons](../button/) inside:
  70. ```html
  71. {{</* hackcss-grid >}}
  72. {{< hackcss-cell class="-4of12" >}}
  73. {{< hackcss-card header="Step 1" >}}
  74. {{< hackcss-button type="primary" isblock="true" isghost="true" >}}
  75. <svg id="i-download" viewBox="0 0 32 32" width="24" height="24" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
  76. <path d="M9 22 C0 23 1 12 9 13 6 2 23 2 22 10 32 7 32 23 23 22 M11 26 L16 30 21 26 M16 16 L16 30"></path>
  77. </svg>&nbsp;&nbsp;Download
  78. {{< /hackcss-button >}}
  79. {{< /hackcss-card >}}
  80. {{< /hackcss-cell >}}
  81. {{< hackcss-cell class="-4of12" >}}
  82. {{< hackcss-card header="Step 2" >}}
  83. {{< hackcss-button type="info" isblock="true" isghost="true" >}}
  84. <svg id="i-code" aria-labelledby="source-label" viewBox="0 0 32 32" width="24" height="24" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
  85. <path d="M10 9 L3 17 10 25 M22 9 L29 17 22 25 M18 7 L14 27" />
  86. </svg>&nbsp;&nbsp;Install
  87. {{< /hackcss-button >}}
  88. {{< /hackcss-card >}}
  89. {{< /hackcss-cell >}}
  90. {{< hackcss-cell class="-4of12" >}}
  91. {{< hackcss-card header="Step 3" >}}
  92. {{< hackcss-button type="success" isblock="true" isghost="true" >}}
  93. <svg id="i-creditcard" viewBox="0 0 32 32" width="24" height="24" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
  94. <path d="M2 7 L2 25 30 25 30 7 Z M5 18 L9 18 M5 21 L11 21" />
  95. <path d="M2 11 L2 13 30 13 30 11 Z" fill="currentColor" />
  96. </svg>&nbsp;&nbsp;Profit
  97. {{< /hackcss-button >}}
  98. {{< /hackcss-card >}}
  99. {{< /hackcss-cell >}}
  100. {{< /hackcss-grid */>}}
  101. ```
  102. {{< hackcss-grid >}}
  103. {{< hackcss-cell class="-4of12" >}}
  104. {{< hackcss-card header="Step 1" >}}
  105. {{< hackcss-button type="primary" isblock="true" isghost="true" >}}
  106. <svg id="i-download" viewBox="0 0 32 32" width="24" height="24" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
  107. <path d="M9 22 C0 23 1 12 9 13 6 2 23 2 22 10 32 7 32 23 23 22 M11 26 L16 30 21 26 M16 16 L16 30"></path>
  108. </svg>&nbsp;&nbsp;Download
  109. {{< /hackcss-button >}}
  110. {{< /hackcss-card >}}
  111. {{< /hackcss-cell >}}
  112. {{< hackcss-cell class="-4of12" >}}
  113. {{< hackcss-card header="Step 2" >}}
  114. {{< hackcss-button type="info" isblock="true" isghost="true" >}}
  115. <svg id="i-code" aria-labelledby="source-label" viewBox="0 0 32 32" width="24" height="24" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
  116. <path d="M10 9 L3 17 10 25 M22 9 L29 17 22 25 M18 7 L14 27" />
  117. </svg>&nbsp;&nbsp;Install
  118. {{< /hackcss-button >}}
  119. {{< /hackcss-card >}}
  120. {{< /hackcss-cell >}}
  121. {{< hackcss-cell class="-4of12" >}}
  122. {{< hackcss-card header="Step 3" >}}
  123. {{< hackcss-button type="success" isblock="true" isghost="true" >}}
  124. <svg id="i-creditcard" viewBox="0 0 32 32" width="24" height="24" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
  125. <path d="M2 7 L2 25 30 25 30 7 Z M5 18 L9 18 M5 21 L11 21" />
  126. <path d="M2 11 L2 13 30 13 30 11 Z" fill="currentColor" />
  127. </svg>&nbsp;&nbsp;Profit
  128. {{< /hackcss-button >}}
  129. {{< /hackcss-card >}}
  130. {{< /hackcss-cell >}}
  131. {{< /hackcss-grid >}}
  132. Aligning three [SVG Favicons]({{< relref "svg-favicon" >}}) using `-around` modifier:
  133. ```html
  134. {{</* hackcss-grid class="-around" >}}
  135. {{< hackcss-cell class="-2of12" >}}
  136. <img src="data:image/svg+xml,%3Csvg%20viewBox='0%200%2046%2045'%20xmlns='http://www.w3.org/2000/svg'%3E%3Ctitle%3EAfter%20Dark%3C/title%3E%3Cpath%20d='M.708%2045L23%20.416%2045.292%2045H.708zM35%2038L23%2019%2011%2038h24z'%20fill='%23f00'/%3E%3C/svg%3E">
  137. {{< /hackcss-cell >}}
  138. {{< hackcss-cell class="-2of12" >}}
  139. <img src="data:image/svg+xml,%3Csvg%20viewBox='0%200%2046%2045'%20xmlns='http://www.w3.org/2000/svg'%3E%3Ctitle%3EAfter%20Dark%3C/title%3E%3Cpath%20d='M.708%2045L23%20.416%2045.292%2045H.708zM35%2038L23%2019%2011%2038h24z'%20fill='lime'/%3E%3C/svg%3E">
  140. {{< /hackcss-cell >}}
  141. {{< hackcss-cell class="-2of12" >}}
  142. <img src="data:image/svg+xml,%3Csvg%20viewBox='0%200%2046%2045'%20xmlns='http://www.w3.org/2000/svg'%3E%3Ctitle%3EAfter%20Dark%3C/title%3E%3Cpath%20d='M.708%2045L23%20.416%2045.292%2045H.708zM35%2038L23%2019%2011%2038h24z'%20fill='%2300f'/%3E%3C/svg%3E">
  143. {{< /hackcss-cell >}}
  144. {{< /hackcss-grid */>}}
  145. ```
  146. {{< hackcss-grid class="-around" >}}
  147. {{< hackcss-cell class="-2of12" >}}
  148. <img src="data:image/svg+xml,%3Csvg%20viewBox='0%200%2046%2045'%20xmlns='http://www.w3.org/2000/svg'%3E%3Ctitle%3EAfter%20Dark%3C/title%3E%3Cpath%20d='M.708%2045L23%20.416%2045.292%2045H.708zM35%2038L23%2019%2011%2038h24z'%20fill='%23f00'/%3E%3C/svg%3E">
  149. {{< /hackcss-cell >}}
  150. {{< hackcss-cell class="-2of12" >}}
  151. <img src="data:image/svg+xml,%3Csvg%20viewBox='0%200%2046%2045'%20xmlns='http://www.w3.org/2000/svg'%3E%3Ctitle%3EAfter%20Dark%3C/title%3E%3Cpath%20d='M.708%2045L23%20.416%2045.292%2045H.708zM35%2038L23%2019%2011%2038h24z'%20fill='lime'/%3E%3C/svg%3E">
  152. {{< /hackcss-cell >}}
  153. {{< hackcss-cell class="-2of12" >}}
  154. <img src="data:image/svg+xml,%3Csvg%20viewBox='0%200%2046%2045'%20xmlns='http://www.w3.org/2000/svg'%3E%3Ctitle%3EAfter%20Dark%3C/title%3E%3Cpath%20d='M.708%2045L23%20.416%2045.292%2045H.708zM35%2038L23%2019%2011%2038h24z'%20fill='%2300f'/%3E%3C/svg%3E">
  155. {{< /hackcss-cell >}}
  156. {{< /hackcss-grid >}}
  157. See the {{< external text="hackcss" href="https://hackcss.egoist.moe/" />}} docs for full list of flexbox modifiers available. Reference the following resources for additional help:
  158. - {{< external "https://philipwalton.github.io/solved-by-flexbox/" "Solved by Flexbox" />}} for cleaner, hack-free CSS
  159. - {{< external "https://www.w3.org/TR/css-flexbox-1/" "CSS Flexible Box Layout Module" />}} for Level 1 spec on W3C