Skip to content

Layout

Used for quick layout.

Basic Usage

The Layout component provides a 24-column grid system. By setting the span property on wd-col, columns are created by calculating the current content's percentage.

Note: The column layout only provides layout, i.e., element width. Users can define internal styles as needed through custom-class or by modifying internal tags.

html
<wd-row>
  <wd-col :span="24"><view class="bg-dark1">span: 24</view></wd-col>
</wd-row>
<wd-row>
  <wd-col :span="12"><view class="bg-dark">span: 12</view></wd-col>
  <wd-col :span="12"><view class="bg-light">span: 12</view></wd-col>
</wd-row>
<wd-row>
  <wd-col :span="8"><view class="bg-dark">span: 8</view></wd-col>
  <wd-col :span="8"><view class="bg-light">span: 8</view></wd-col>
  <wd-col :span="8"><view class="bg-dark">span: 8</view></wd-col>
</wd-row>
<wd-row>
  <wd-col :span="6"><view class="bg-dark">span: 6</view></wd-col>
  <wd-col :span="6"><view class="bg-light">span: 6</view></wd-col>
  <wd-col :span="6"><view class="bg-dark">span: 6</view></wd-col>
  <wd-col :span="6"><view class="bg-light">span: 6</view></wd-col>
</wd-row>
scss
.bg-dark1,
.bg-dark,
.bg-light{
  border-radius: 4px;
  min-height: 30px;
  text-align: center;
  line-height: 30px;
  font-size: 12px;
  margin-bottom: 10px;
  color: rgba(0, 0, 0, 0.45);
}
.bg-dark1 {
  background: #99a9bf;
  color: #fff;
}
.bg-dark {
  background: #d3dce6;
}
.bg-light {
  background: #e5e9f2;
}

Column Offset

The offset property can set the offset of columns. The calculation method and offset size are the same as span.

html
<wd-row>
  <wd-col :span="4"><view class="bg-dark">span: 4</view></wd-col>
  <wd-col :span="8" :offset="4"><view class="bg-light">span: 8 offset: 4</view></wd-col>
</wd-row>
<wd-row>
  <wd-col :span="8" :offset="4"><view class="bg-dark">span: 8 offset: 4</view></wd-col>
  <wd-col :span="8" :offset="4"><view class="bg-dark">span: 8 offset: 4</view></wd-col>
</wd-row>

Column Spacing

Through the gutter property, you can set the spacing between column elements. The default spacing is 0.

html
<wd-row gutter="20">
  <wd-col :span="8"><view class="bg-dark">span: 8</view></wd-col>
  <wd-col :span="8"><view class="bg-light">span: 8</view></wd-col>
  <wd-col :span="8"><view class="bg-dark">span: 8</view></wd-col>
</wd-row>

Row Attributes

ParameterDescriptionTypeOptionsDefaultVersion
gutterSpacing between column elements (in px)number-0-

Col Attributes

ParameterDescriptionTypeOptionsDefaultVersion
spanColumn element widthnumber-24-
offsetColumn element offset distancenumber-0-

Row External Classes

Class NameDescriptionVersion
custom-classRow root node style-

Col External Classes

Class NameDescriptionVersion
custom-classCol root node style-

Source Code

Documentation
Component

Released under the MIT License.

Ask me