Skip to content

巧用 Element 自适应布局

发表于
更新于
字数总计
阅读量

在线文档查看 Element - 响应式布局

自适应范围

Element 参照了 Bootstrap 的 响应式设计,预设了五个响应尺寸:xs、sm、md、lg 和 xl。

以下是各自代表的自适应范围:

尺寸范围优先级
xsonly screen and (max-width: 767px)小屏优先级最高
smonly screen and (min-width: 768px)-
mdonly screen and (min-width: 992px)-
lgonly screen and (min-width: 1200px)-
xlonly screen and (min-width: 1920px)宽屏优先级最高
span默认,除以上情况外生效优先级最低

使用示例

vue
<el-row :gutter="10">
  <el-col :xs="24" :sm="16" :md="12" :lg="8" :xl="4">
    <div class="grid-content ep-bg-purple" />
  </el-col>
  <el-col :span="24" :sm="8" :md="12" :lg="16" :xl="20">
    <div class="grid-content ep-bg-purple-light" />
  </el-col>
</el-row>

提示

xs 只限定于屏幕宽度小于768px生效,而 span 可补足其他所有情况。