Grid / Layout Grid - 图1

Grid Svelte Component

Grid Svelte component represents Framework7’s Layout Grid.

Grid Components

There are following components included:

  • Row - grid row
  • Col - grid column (cell)

Grid Properties

PropTypeDefaultDescription
<Row> properties
noGapbooleanfalseRemoves spacing between columns
tagstringdivDefines which tag must be used to render row element. Can be div or p
resizablebooleanfalseMakes row resizable
resizableAbsolutebooleanfalseEnables absolute resizing (in px)
resizableFixedbooleanfalseKeeps resizable row in fixed size (not resizable)
resizableHhandlerbooleantrueAdds resize handler element (between rows) to resize them
<Col> properties
tagstringdivDefines which tag must be used to render row element. Can be div or span
widthnumber
string
autoColumn width. Check available Column Sizes
xsmallnumberColumn width when app width >= 480px
smallnumberColumn width when app width >= 568px
mediumnumberColumn width when app width >= 768px
largenumberColumn width when app width >= 1024px
xlargenumberColumn width when app width >= 1200px
resizablebooleanfalseMakes column resizable
resizableAbsolutebooleanfalseEnables absolute resizing (in px)
resizableFixedbooleanfalseKeeps resizable column in fixed size (not resizable)
resizableHandlerbooleantrueAdds resize handler element (between columns) to resize them

Grid Events

EventDescription
<Row> events
gridResizeEvent will be triggered on resizable grid row resize
<Col> events
gridResizeEvent will be triggered on resizable grid column resize

Examples

  1. <Page class="grid-demo">
  2. <Navbar title="Grid / Layout"></Navbar>
  3. <Block>
  4. <p>Columns within a row are automatically set to have equal width. Otherwise you can define your column with pourcentage of screen you want.</p>
  5. </Block>
  6. <BlockTitle>Columns with gap</BlockTitle>
  7. <Block>
  8. <Row>
  9. <Col>50% (.col)</Col>
  10. <Col>50% (.col)</Col>
  11. </Row>
  12. <Row>
  13. <Col>25% (.col)</Col>
  14. <Col>25% (.col)</Col>
  15. <Col>25% (.col)</Col>
  16. <Col>25% (.col)</Col>
  17. </Row>
  18. <Row>
  19. <Col>33% (.col)</Col>
  20. <Col>33% (.col)</Col>
  21. <Col>33% (.col)</Col>
  22. </Row>
  23. <Row>
  24. <Col>20% (.col)</Col>
  25. <Col>20% (.col)</Col>
  26. <Col>20% (.col)</Col>
  27. <Col>20% (.col)</Col>
  28. <Col>20% (.col)</Col>
  29. </Row>
  30. <Row>
  31. <Col width="33">33% (.col-33)</Col>
  32. <Col width="66">66% (.col-66)</Col>
  33. </Row>
  34. <Row>
  35. <Col width="25">25% (.col-25)</Col>
  36. <Col width="25">25% (.col-25)</Col>
  37. <Col width="50">50% (.col-50)</Col>
  38. </Row>
  39. <Row>
  40. <Col width="75">75% (.col-75)</Col>
  41. <Col width="25">25% (.col-25)</Col>
  42. </Row>
  43. <Row>
  44. <Col width="80">80% (.col-80)</Col>
  45. <Col width="20">20% (.col-20)</Col>
  46. </Row>
  47. </Block>
  48. <BlockTitle>No gap between columns</BlockTitle>
  49. <Block>
  50. <Row noGap>
  51. <Col>50% (.col)</Col>
  52. <Col>50% (.col)</Col>
  53. </Row>
  54. <Row noGap>
  55. <Col>25% (.col)</Col>
  56. <Col>25% (.col)</Col>
  57. <Col>25% (.col)</Col>
  58. <Col>25% (.col)</Col>
  59. </Row>
  60. <Row noGap>
  61. <Col>33% (.col)</Col>
  62. <Col>33% (.col)</Col>
  63. <Col>33% (.col)</Col>
  64. </Row>
  65. <Row noGap>
  66. <Col>20% (.col)</Col>
  67. <Col>20% (.col)</Col>
  68. <Col>20% (.col)</Col>
  69. <Col>20% (.col)</Col>
  70. <Col>20% (.col)</Col>
  71. </Row>
  72. <Row noGap>
  73. <Col width="33">33% (.col-33)</Col>
  74. <Col width="66">66% (.col-66)</Col>
  75. </Row>
  76. <Row noGap>
  77. <Col width="25">25% (.col-25)</Col>
  78. <Col width="25">25% (.col-25)</Col>
  79. <Col width="50">50% (.col-50)</Col>
  80. </Row>
  81. <Row noGap>
  82. <Col width="75">75% (.col-75)</Col>
  83. <Col width="25">25% (.col-25)</Col>
  84. </Row>
  85. <Row noGap>
  86. <Col width="80">80% (.col-80)</Col>
  87. <Col width="20">20% (.col-20)</Col>
  88. </Row>
  89. </Block>
  90. <BlockTitle>Nested</BlockTitle>
  91. <Block>
  92. <Row>
  93. <Col>50% (.col)
  94. <Row>
  95. <Col>50% (.col)</Col>
  96. <Col>50% (.col)</Col>
  97. </Row>
  98. </Col>
  99. <Col>50% (.col)
  100. <Row>
  101. <Col width="33">33% (.col-33)</Col>
  102. <Col width="66">66% (.col-66)</Col>
  103. </Row>
  104. </Col>
  105. </Row>
  106. </Block>
  107. <BlockTitle>Responsive Grid</BlockTitle>
  108. <Block>
  109. <p>Grid cells have different size on Phone/Tablet</p>
  110. <Row>
  111. <Col width="100" medium="50">.col-100.tablet-50</Col>
  112. <Col width="100" medium="50">.col-100.tablet-50</Col>
  113. </Row>
  114. <Row>
  115. <Col width="50" medium="25">.col-50.tablet-25</Col>
  116. <Col width="50" medium="25">.col-50.tablet-25</Col>
  117. <Col width="50" medium="25">.col-50.tablet-25</Col>
  118. <Col width="50" medium="25">.col-50.tablet-25</Col>
  119. </Row>
  120. <Row>
  121. <Col width="100" medium="40">.col-100.tablet-40</Col>
  122. <Col width="50" medium="60">.col-50.tablet-60</Col>
  123. <Col width="50" medium="66">.col-50.tablet-66</Col>
  124. <Col width="100" medium="33">.col-100.tablet-33</Col>
  125. </Row>
  126. </Block>
  127. <BlockTitle>Resizable Cols</BlockTitle>
  128. <Block class="grid-resizable-demo">
  129. <Row>
  130. <Col resizable style="min-width: 20px">1</Col>
  131. <Col resizable style="min-width: 20px">2</Col>
  132. <Col resizable style="min-width: 20px">3</Col>
  133. </Row>
  134. </Block>
  135. <BlockTitle>Resizable Fixed Col</BlockTitle>
  136. <BlockHeader>2nd column has fixed size</BlockHeader>
  137. <Block class="grid-resizable-demo">
  138. <Row>
  139. <Col resizable style="min-width: 20px">1</Col>
  140. <Col resizable resizableFixed style="min-width: 20px">2</Col>
  141. <Col resizable style="min-width: 20px">3</Col>
  142. </Row>
  143. </Block>
  144. <BlockTitle>Resizable Grid</BlockTitle>
  145. <Block class="grid-resizable-demo">
  146. <Row class="align-items-stretch" style="height: 300px">
  147. <Col resizable class="demo-col-center-content" style="min-width: 50px">Left</Col>
  148. <Col resizable class="display-flex flex-direction-column" style="padding: 0px; border: none; min-width: 50px; background-color: transparent">
  149. <Row resizable style="height: 50%; min-height: 50px">
  150. <Col class="demo-col-center-content" style="height: 100%">Center Top</Col>
  151. </Row>
  152. <Row resizable style="height: 50%; min-height: 50px">
  153. <Col class="demo-col-center-content" style="height: 100%">Center Bottom</Col>
  154. </Row>
  155. </Col>
  156. <Col resizable class="demo-col-center-content" style="min-width: 50px">Right</Col>
  157. </Row>
  158. </Block>
  159. </Page>
  160. <style>
  161. :global(.grid-demo div[class*="col"]) {
  162. background: #fff;
  163. text-align: center;
  164. color: #000;
  165. border: 1px solid #ddd;
  166. padding: 5px;
  167. margin-bottom: 15px;
  168. font-size: 12px;
  169. }
  170. :global(.grid-resizable-demo) {
  171. --f7-grid-row-gap: 16px;
  172. }
  173. :global(.grid-resizable-demo div[class*="col"]) {
  174. margin-bottom: 0;
  175. }
  176. :global(.grid-resizable-demo .demo-col-center-content) {
  177. display: flex;
  178. align-items: center;
  179. justify-content: center;
  180. }
  181. </style>
  182. <script>
  183. import {Page, Navbar, Block, BlockTitle, Row, Col, BlockHeader} from 'framework7-svelte';
  184. </script>

← Gauge

Icon →