跳到主要内容

布局 Layout

Layout 提供了 ti-towti-col 两个组件来进行行列布局。

安装使用

{
// 原生小程序
"usingComponents": {
"ti-row": "@titian-design/weapp/row/index",
"ti-col": "@titian-design/weapp/col/index"
},
// titan-cli搭建的项目
"usingComponents": {
"ti-row": "platform://titian-mp/ti-row",
"ti-col": "platform://titian-mp/ti-col"
}
}

用法示例

栅格配置

栅格占位格数,为 0 时相当于 display: none

<ti-row>
<ti-col span="{{24}}">span-24</ti-col>
</ti-row>

<ti-row>
<ti-col span="{{12}}">span-12</ti-col>
<ti-col span="{{12}}">span-12</ti-col>
</ti-row>

<ti-row>
<ti-col span="{{8}}">span-8</ti-col>
<ti-col span="{{8}}">span-8</ti-col>
<ti-col span="{{8}}">span-8</ti-col>
</ti-row>

<ti-row>
<ti-col span="{{6}}">span-6</ti-col>
<ti-col span="{{6}}">span-6</ti-col>
<ti-col span="{{6}}">span-6</ti-col>
<ti-col span="{{6}}">span-6</ti-col>
</ti-row>

偏移量设置

栅格左侧的偏移格数

<ti-row>
<ti-col span="{{12}}" offset="{{12}}">span-12</ti-col>
</ti-row>

<ti-row>
<ti-col offset="{{8}}" span="{{8}}">offset-8 span-8</ti-col>
<ti-col span="{{8}}">span-8</ti-col>
</ti-row>

<ti-row>
<ti-col offset="{{6}}" span="{{6}}">span-6</ti-col>
<ti-col offset="{{6}}" span="{{6}}">span-6</ti-col>
</ti-row>

配置栅格间隔

<ti-row gutter="{{12}}">
<ti-col span="{{12}}">gutter-12 span-12</ti-col>
<ti-col span="{{12}}">gutter-12 span-12</ti-col>
</ti-row>

<ti-row gutter="{{4}}">
<ti-col span="{{8}}">gutter-4 span-8</ti-col>
<ti-col span="{{8}}">gutter-4 span-8</ti-col>
<ti-col span="{{8}}">gutter-4 span-8</ti-col>
</ti-row>

使用浮动布局

<ti-row flex="{{false}}">
<ti-col span="{{12}}">span-12</ti-col>
<ti-col span="{{12}}">span-12</ti-col>
</ti-row>

ti-row API

属性 Properties

名称类型是否必填默认值说明备注
flexbooleantrue是否启用 flex 布局, 当值为false时,使用浮动布局-
gutternumber0列元素之间的距离-

可扩展样式名 External Class

类名说明备注
ext-class根节点可扩展的类名-

ti-col API

属性 Properties

名称类型是否必填默认值说明备注
spannumber-栅格占位格数,为 0 时相当于 display: none-
offsetnumber-栅格左侧的偏移格数-

可扩展样式名 External Class

类名说明备注
ext-class根节点可扩展的类名-