js-components-grid-col.md 16.2 KB
Newer Older
Z
zengyawen 已提交
1
# grid-col<a name="ZH-CN_TOPIC_0000001237760449"></a>
Z
zengyawen 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

grid-col是栅格布局容器grid-row的子容器组件。

## 权限列表<a name="section11257113618419"></a>



## 子组件<a name="section9288143101012"></a>

支持。

## 属性<a name="section1976213199113"></a>

除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性:

Z
zengyawen 已提交
17
<table><thead align="left"><tr><th class="cellrowborder" valign="top" width="23.119999999999997%" id="mcps1.1.6.1.1"><p>名称</p>
Z
zengyawen 已提交
18
</th>
Z
zengyawen 已提交
19
<th class="cellrowborder" valign="top" width="23.119999999999997%" id="mcps1.1.6.1.2"><p>类型</p>
Z
zengyawen 已提交
20
</th>
Z
zengyawen 已提交
21
<th class="cellrowborder" valign="top" width="10.48%" id="mcps1.1.6.1.3"><p>默认值</p>
Z
zengyawen 已提交
22
</th>
Z
zengyawen 已提交
23
<th class="cellrowborder" valign="top" width="7.449999999999999%" id="mcps1.1.6.1.4"><p>必填</p>
Z
zengyawen 已提交
24
</th>
Z
zengyawen 已提交
25
<th class="cellrowborder" valign="top" width="35.83%" id="mcps1.1.6.1.5"><p>描述</p>
Z
zengyawen 已提交
26 27 28
</th>
</tr>
</thead>
Z
zengyawen 已提交
29
<tbody><tr><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p>xs</p>
Z
zengyawen 已提交
30
</td>
Z
zengyawen 已提交
31
<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p>number|object</p>
Z
zengyawen 已提交
32
</td>
Z
zengyawen 已提交
33
<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p>-</p>
Z
zengyawen 已提交
34
</td>
Z
zengyawen 已提交
35
<td class="cellrowborder" valign="top" width="7.449999999999999%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
36
</td>
Z
zengyawen 已提交
37
<td class="cellrowborder" valign="top" width="35.83%" headers="mcps1.1.6.1.5 "><p>在分辨率为xs模式下,设置该项占用列数与偏移列数,当值为number类型时,仅设置列数,也可通过object同时设置占用列数与偏移列数,如{"span": 1, "offset": 0}</p>
Z
zengyawen 已提交
38 39
</td>
</tr>
Z
zengyawen 已提交
40
<tr><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p>sm</p>
Z
zengyawen 已提交
41
</td>
Z
zengyawen 已提交
42
<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p>number|object</p>
Z
zengyawen 已提交
43
</td>
Z
zengyawen 已提交
44
<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p>-</p>
Z
zengyawen 已提交
45
</td>
Z
zengyawen 已提交
46
<td class="cellrowborder" valign="top" width="7.449999999999999%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
47
</td>
Z
zengyawen 已提交
48
<td class="cellrowborder" valign="top" width="35.83%" headers="mcps1.1.6.1.5 "><p>在分辨率为sm模式下,该项占用列数与偏移列数,当值为number类型时,仅设置列数,也可通过object同时设置占用列数与偏移列数,如{"span": 1, "offset": 0}</p>
Z
zengyawen 已提交
49 50
</td>
</tr>
Z
zengyawen 已提交
51
<tr><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p>md</p>
Z
zengyawen 已提交
52
</td>
Z
zengyawen 已提交
53
<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p>number|object</p>
Z
zengyawen 已提交
54
</td>
Z
zengyawen 已提交
55
<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p>-</p>
Z
zengyawen 已提交
56
</td>
Z
zengyawen 已提交
57
<td class="cellrowborder" valign="top" width="7.449999999999999%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
58
</td>
Z
zengyawen 已提交
59
<td class="cellrowborder" valign="top" width="35.83%" headers="mcps1.1.6.1.5 "><p>在分辨率为md模式下,该项占用列数与偏移列数,当值为number类型时,仅设置列数,也可通过object同时设置占用列数与偏移列数,如{"span": 1, "offset": 0}</p>
Z
zengyawen 已提交
60 61
</td>
</tr>
Z
zengyawen 已提交
62
<tr><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p>lg</p>
Z
zengyawen 已提交
63
</td>
Z
zengyawen 已提交
64
<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p>number|object</p>
Z
zengyawen 已提交
65
</td>
Z
zengyawen 已提交
66
<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p>-</p>
Z
zengyawen 已提交
67
</td>
Z
zengyawen 已提交
68
<td class="cellrowborder" valign="top" width="7.449999999999999%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
69
</td>
Z
zengyawen 已提交
70
<td class="cellrowborder" valign="top" width="35.83%" headers="mcps1.1.6.1.5 "><p>在分辨率为lg模式下,该项占用列数与偏移列数,当值为number类型时,仅设置列数,也可通过object同时设置占用列数与偏移列数,如{"span": 1, "offset": 0}</p>
Z
zengyawen 已提交
71 72
</td>
</tr>
Z
zengyawen 已提交
73
<tr><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p>span</p>
Z
zengyawen 已提交
74
</td>
Z
zengyawen 已提交
75
<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p>number</p>
Z
zengyawen 已提交
76
</td>
Z
zengyawen 已提交
77
<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p>1</p>
Z
zengyawen 已提交
78
</td>
Z
zengyawen 已提交
79
<td class="cellrowborder" valign="top" width="7.449999999999999%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
80
</td>
Z
zengyawen 已提交
81
<td class="cellrowborder" valign="top" width="35.83%" headers="mcps1.1.6.1.5 "><p>在未设置明确断点时,默认占用列数</p>
Z
zengyawen 已提交
82 83
</td>
</tr>
Z
zengyawen 已提交
84
<tr><td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.1 "><p>offset</p>
Z
zengyawen 已提交
85
</td>
Z
zengyawen 已提交
86
<td class="cellrowborder" valign="top" width="23.119999999999997%" headers="mcps1.1.6.1.2 "><p>number</p>
Z
zengyawen 已提交
87
</td>
Z
zengyawen 已提交
88
<td class="cellrowborder" valign="top" width="10.48%" headers="mcps1.1.6.1.3 "><p>0</p>
Z
zengyawen 已提交
89
</td>
Z
zengyawen 已提交
90
<td class="cellrowborder" valign="top" width="7.449999999999999%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
91
</td>
Z
zengyawen 已提交
92
<td class="cellrowborder" valign="top" width="35.83%" headers="mcps1.1.6.1.5 "><p>未设置具体分辨率模式下偏移时,当前元素延容器布局方向,默认偏移的列数</p>
Z
zengyawen 已提交
93 94 95 96 97 98 99 100 101
</td>
</tr>
</tbody>
</table>

## 样式<a name="section1948816404128"></a>

除支持[通用样式](js-components-common-styles.md)外,还支持如下样式:

Z
zengyawen 已提交
102
<table><thead align="left"><tr><th class="cellrowborder" valign="top" width="23.11768823117688%" id="mcps1.1.6.1.1"><p>名称</p>
Z
zengyawen 已提交
103
</th>
Z
zengyawen 已提交
104
<th class="cellrowborder" valign="top" width="12.218778122187782%" id="mcps1.1.6.1.2"><p>类型</p>
Z
zengyawen 已提交
105
</th>
Z
zengyawen 已提交
106
<th class="cellrowborder" valign="top" width="13.03869613038696%" id="mcps1.1.6.1.3"><p>默认值</p>
Z
zengyawen 已提交
107
</th>
Z
zengyawen 已提交
108
<th class="cellrowborder" valign="top" width="8.4991500849915%" id="mcps1.1.6.1.4"><p>必填</p>
Z
zengyawen 已提交
109
</th>
Z
zengyawen 已提交
110
<th class="cellrowborder" valign="top" width="43.12568743125688%" id="mcps1.1.6.1.5"><p>描述</p>
Z
zengyawen 已提交
111 112 113
</th>
</tr>
</thead>
Z
zengyawen 已提交
114
<tbody><tr><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p>flex-direction</p>
Z
zengyawen 已提交
115
</td>
Z
zengyawen 已提交
116
<td class="cellrowborder" valign="top" width="12.218778122187782%" headers="mcps1.1.6.1.2 "><p>string</p>
Z
zengyawen 已提交
117
</td>
Z
zengyawen 已提交
118
<td class="cellrowborder" valign="top" width="13.03869613038696%" headers="mcps1.1.6.1.3 "><p>row</p>
Z
zengyawen 已提交
119
</td>
Z
zengyawen 已提交
120
<td class="cellrowborder" valign="top" width="8.4991500849915%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
121
</td>
Z
zengyawen 已提交
122 123
<td class="cellrowborder" valign="top" width="43.12568743125688%" headers="mcps1.1.6.1.5 "><p>flex容器主轴方向。可选项有:</p>
<ul><li>column:垂直方向从上到下</li><li>row:水平方向从左到右</li></ul>
Z
zengyawen 已提交
124 125
</td>
</tr>
Z
zengyawen 已提交
126
<tr><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p>flex-wrap</p>
Z
zengyawen 已提交
127
</td>
Z
zengyawen 已提交
128
<td class="cellrowborder" valign="top" width="12.218778122187782%" headers="mcps1.1.6.1.2 "><p>string</p>
Z
zengyawen 已提交
129
</td>
Z
zengyawen 已提交
130
<td class="cellrowborder" valign="top" width="13.03869613038696%" headers="mcps1.1.6.1.3 "><p>nowrap</p>
Z
zengyawen 已提交
131
</td>
Z
zengyawen 已提交
132
<td class="cellrowborder" valign="top" width="8.4991500849915%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
133
</td>
Z
zengyawen 已提交
134 135
<td class="cellrowborder" valign="top" width="43.12568743125688%" headers="mcps1.1.6.1.5 "><p>flex容器是单行还是多行显示,该值暂不支持动态修改。可选项有:</p>
<ul><li>nowrap:不换行,单行显示。</li><li>wrap:换行,多行显示。</li></ul>
Z
zengyawen 已提交
136 137
</td>
</tr>
Z
zengyawen 已提交
138
<tr><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p>justify-content</p>
Z
zengyawen 已提交
139
</td>
Z
zengyawen 已提交
140
<td class="cellrowborder" valign="top" width="12.218778122187782%" headers="mcps1.1.6.1.2 "><p>string</p>
Z
zengyawen 已提交
141
</td>
Z
zengyawen 已提交
142
<td class="cellrowborder" valign="top" width="13.03869613038696%" headers="mcps1.1.6.1.3 "><p>flex-start</p>
Z
zengyawen 已提交
143
</td>
Z
zengyawen 已提交
144
<td class="cellrowborder" valign="top" width="8.4991500849915%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
145
</td>
Z
zengyawen 已提交
146 147
<td class="cellrowborder" valign="top" width="43.12568743125688%" headers="mcps1.1.6.1.5 "><p>flex容器当前行的主轴对齐格式。可选项有:</p>
<ul><li>flex-start:项目位于容器的开头。</li><li>flex-end:项目位于容器的结尾。</li><li>center:项目位于容器的中心。</li><li>space-between:项目位于各行之间留有空白的容器内。</li><li>space-around:项目位于各行之前、之间、之后都留有空白的容器内。</li></ul>
Z
zengyawen 已提交
148 149
</td>
</tr>
Z
zengyawen 已提交
150
<tr><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p>align-items</p>
Z
zengyawen 已提交
151
</td>
Z
zengyawen 已提交
152
<td class="cellrowborder" valign="top" width="12.218778122187782%" headers="mcps1.1.6.1.2 "><p>string</p>
Z
zengyawen 已提交
153
</td>
Z
zengyawen 已提交
154
<td class="cellrowborder" valign="top" width="13.03869613038696%" headers="mcps1.1.6.1.3 "><p>stretch</p>
Z
zengyawen 已提交
155
</td>
Z
zengyawen 已提交
156
<td class="cellrowborder" valign="top" width="8.4991500849915%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
157
</td>
Z
zengyawen 已提交
158 159
<td class="cellrowborder" valign="top" width="43.12568743125688%" headers="mcps1.1.6.1.5 "><p>flex容器当前行的交叉轴对齐格式,可选值为:</p>
<ul><li>stretch:弹性元素被在交叉轴方向被拉伸到与容器相同的高度或宽度。</li><li>flex-start:元素向交叉轴起点对齐。</li><li>flex-end:元素向交叉轴终点对齐。</li><li>center:元素在交叉轴居中。</li></ul>
Z
zengyawen 已提交
160 161
</td>
</tr>
Z
zengyawen 已提交
162
<tr><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p>align-content</p>
Z
zengyawen 已提交
163
</td>
Z
zengyawen 已提交
164
<td class="cellrowborder" valign="top" width="12.218778122187782%" headers="mcps1.1.6.1.2 "><p>string</p>
Z
zengyawen 已提交
165
</td>
Z
zengyawen 已提交
166
<td class="cellrowborder" valign="top" width="13.03869613038696%" headers="mcps1.1.6.1.3 "><p>flex-start</p>
Z
zengyawen 已提交
167
</td>
Z
zengyawen 已提交
168
<td class="cellrowborder" valign="top" width="8.4991500849915%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
169
</td>
Z
zengyawen 已提交
170 171
<td class="cellrowborder" valign="top" width="43.12568743125688%" headers="mcps1.1.6.1.5 "><p>交叉轴中有额外的空间时,多行内容对齐格式,可选值为:</p>
<ul><li>flex-start:所有行从交叉轴起点开始填充。第一行的交叉轴起点边和容器的交叉轴起点边对齐。接下来的每一行紧跟前一行。</li><li>flex-end:所有行从交叉轴末尾开始填充。最后一行的交叉轴终点和容器的交叉轴终点对齐。同时所有后续行与前一个对齐。</li><li>center:所有行朝向容器的中心填充。每行互相紧挨,相对于容器居中对齐。容器的交叉轴起点边和第一行的距离相等于容器的交叉轴终点边和最后一行的距离。</li><li>space-between:所有行在容器中平均分布。相邻两行间距相等。容器的交叉轴起点边和终点边分别与第一行和最后一行的边对齐。</li><li>space-around:所有行在容器中平均分布,相邻两行间距相等。容器的交叉轴起点边和终点边分别与第一行和最后一行的距离是相邻两行间距的一半。</li></ul>
Z
zengyawen 已提交
172 173
</td>
</tr>
Z
zengyawen 已提交
174
<tr><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p>display</p>
Z
zengyawen 已提交
175
</td>
Z
zengyawen 已提交
176
<td class="cellrowborder" valign="top" width="12.218778122187782%" headers="mcps1.1.6.1.2 "><p>string</p>
Z
zengyawen 已提交
177
</td>
Z
zengyawen 已提交
178
<td class="cellrowborder" valign="top" width="13.03869613038696%" headers="mcps1.1.6.1.3 "><p>flex</p>
Z
zengyawen 已提交
179
</td>
Z
zengyawen 已提交
180
<td class="cellrowborder" valign="top" width="8.4991500849915%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
181
</td>
Z
zengyawen 已提交
182 183
<td class="cellrowborder" valign="top" width="43.12568743125688%" headers="mcps1.1.6.1.5 "><p>确定该元素视图框的类型,该值暂不支持动态修改。可选值为:</p>
<ul><li>flex:弹性布局</li><li>grid:网格布局</li><li>none:不渲染此元素</li></ul>
Z
zengyawen 已提交
184 185
</td>
</tr>
Z
zengyawen 已提交
186
<tr><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p>grid-template-[columns|rows]</p>
Z
zengyawen 已提交
187
</td>
Z
zengyawen 已提交
188
<td class="cellrowborder" valign="top" width="12.218778122187782%" headers="mcps1.1.6.1.2 "><p>string</p>
Z
zengyawen 已提交
189
</td>
Z
zengyawen 已提交
190
<td class="cellrowborder" valign="top" width="13.03869613038696%" headers="mcps1.1.6.1.3 "><p>1行1列</p>
Z
zengyawen 已提交
191
</td>
Z
zengyawen 已提交
192
<td class="cellrowborder" valign="top" width="8.4991500849915%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
193
</td>
Z
zengyawen 已提交
194 195 196 197 198 199 200
<td class="cellrowborder" valign="top" width="43.12568743125688%" headers="mcps1.1.6.1.5 "><p>用于设置当前网格布局行和列的数量,不设置时默认1行1列,仅当display为grid时生效。</p>
<p>示例:如设置grid-template-columns为:</p>
<p>(1) 50px 100px 60px:分三列,第一列50px,第二列100px,第三列60px;</p>
<p>(2) 1fr 1fr 2fr:分三列,将父组件允许的宽分为4等份,第一列占1份,第二列占一份,第三列占2份;</p>
<p>(3) 30% 20% 50%:分三列,将父组件允许的宽为基准,第一列占30%,第二列占20%,第三列占50%;</p>
<p>(4) repeat(2,100px):分两列,第一列100px,第二列100px;</p>
<p>(5) auto 1fr 1fr:分三列,第一列自适应内部子组件所需宽度,剩余空间分为两等份,第二列占一份,第三列占一份。</p>
Z
zengyawen 已提交
201 202
</td>
</tr>
Z
zengyawen 已提交
203
<tr><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p>grid-[columns|rows]-gap</p>
Z
zengyawen 已提交
204
</td>
Z
zengyawen 已提交
205
<td class="cellrowborder" valign="top" width="12.218778122187782%" headers="mcps1.1.6.1.2 "><p>&lt;length&gt;</p>
Z
zengyawen 已提交
206
</td>
Z
zengyawen 已提交
207
<td class="cellrowborder" valign="top" width="13.03869613038696%" headers="mcps1.1.6.1.3 "><p>0</p>
Z
zengyawen 已提交
208
</td>
Z
zengyawen 已提交
209
<td class="cellrowborder" valign="top" width="8.4991500849915%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
210
</td>
Z
zengyawen 已提交
211
<td class="cellrowborder" valign="top" width="43.12568743125688%" headers="mcps1.1.6.1.5 "><p>用于设置行与行的间距或者列与列的间距,也可以支持通过grid-gap设置相同的行列间距,仅当display为grid时生效。</p>
Z
zengyawen 已提交
212 213
</td>
</tr>
Z
zengyawen 已提交
214
<tr><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p>grid-row-[start|end]</p>
Z
zengyawen 已提交
215
</td>
Z
zengyawen 已提交
216
<td class="cellrowborder" valign="top" width="12.218778122187782%" headers="mcps1.1.6.1.2 "><p>number</p>
Z
zengyawen 已提交
217
</td>
Z
zengyawen 已提交
218
<td class="cellrowborder" valign="top" width="13.03869613038696%" headers="mcps1.1.6.1.3 "><p>-</p>
Z
zengyawen 已提交
219
</td>
Z
zengyawen 已提交
220
<td class="cellrowborder" valign="top" width="8.4991500849915%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
221
</td>
Z
zengyawen 已提交
222
<td class="cellrowborder" valign="top" width="43.12568743125688%" headers="mcps1.1.6.1.5 "><p>用于设置当前元素在网格布局中的起止行号,仅当父组件display样式为grid时生效(仅div支持display样式设置为grid)。</p>
Z
zengyawen 已提交
223 224
</td>
</tr>
Z
zengyawen 已提交
225
<tr><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p>grid-column-[start|end]</p>
Z
zengyawen 已提交
226
</td>
Z
zengyawen 已提交
227
<td class="cellrowborder" valign="top" width="12.218778122187782%" headers="mcps1.1.6.1.2 "><p>number</p>
Z
zengyawen 已提交
228
</td>
Z
zengyawen 已提交
229
<td class="cellrowborder" valign="top" width="13.03869613038696%" headers="mcps1.1.6.1.3 "><p>-</p>
Z
zengyawen 已提交
230
</td>
Z
zengyawen 已提交
231
<td class="cellrowborder" valign="top" width="8.4991500849915%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
232
</td>
Z
zengyawen 已提交
233
<td class="cellrowborder" valign="top" width="43.12568743125688%" headers="mcps1.1.6.1.5 "><p>用于设置当前元素在网格布局中的起止列号,仅当父组件display样式为grid时生效(仅div支持display样式设置为grid)。</p>
Z
zengyawen 已提交
234 235 236 237 238 239
</td>
</tr>
</tbody>
</table>

>![](../../public_sys-resources/icon-note.gif) **说明:** 
Z
zengyawen 已提交
240
>不支持宽度相关样式。
Z
zengyawen 已提交
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256

## 事件<a name="section94351031102113"></a>

支持[通用事件](js-components-common-events.md)

## 方法<a name="section2279124532420"></a>

支持[通用方法](js-components-common-methods.md)

## 示例<a name="section2021865273710"></a>

```
<!-- index.hml -->
<div class="container">
  <grid-container id="mygrid" columns="5" gutter="20px" style="background-color: pink;">
    <grid-row style="height:400px;justify-content:space-around;">
Z
zengyawen 已提交
257
      <grid-col span="2">
Z
zengyawen 已提交
258
        <div style="align-items: center;justify-content: center;height: 100%;width: 100%;">
Z
zengyawen 已提交
259
          <text style="color: dodgerblue;" onclick="getCol">Element text</text>
Z
zengyawen 已提交
260 261
        </div>
      </grid-col>
Z
zengyawen 已提交
262
      <grid-col span="3" style="background-color:orange;">
Z
zengyawen 已提交
263
        <div style="width: 100%;height: 100%;padding: 20px;align-items: center;">
Z
zengyawen 已提交
264
          <text onclick="getColWidth">Element text</text>
Z
zengyawen 已提交
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
        </div>
      </grid-col>
    </grid-row>
  </grid-container>
</div>
```

```
/* index.css */
.container {
  flex-direction: column;
  padding-top: 80px;
}
```

```
// index.js
import prompt from '@system.prompt';
export default {
  getCol(e) {
    this.$element('mygrid').getColumns(function (result) {
      prompt.showToast({
        message: e.target.id + ' result = ' + result,
        duration: 3000,
      });
    })
  },
  getColWidth(e) {
    this.$element('mygrid').getColumnWidth(function (result) {
      prompt.showToast({
        message: e.target.id + ' result = ' + result,
        duration: 3000,
      });
    })
  }
}
```

Z
zengyawen 已提交
303
![](figures/grid.gif)
Z
update  
zengyawen 已提交
304