前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ELEMENT简单布局

ELEMENT简单布局

作者头像
算法与编程之美
发布2021-12-08 20:03:10
8840
发布2021-12-08 20:03:10
举报

1 问题描述

本文章通过div盒子和el-container两种方式进行网页的简单布局及嵌套功能,以此表明两者之间的不同。

2 算法描述

(一)使用div盒子装。一般装el-row和el-col。

代码清单 1

<template><div id=""><!-- 头部 --><div class="content"><el-row style="margin-bottom: 0;"><el-col :span="24"><div class="top bg-purple-dark"></div></el-col></el-row></div><!-- 中间 --><div class="card"><el-row><el-col :span="12"><div class="double bg-purple"></div></el-col><el-col :span="12"><div class="double bg-purple-light"></div></el-col></el-row><el-row><el-col :span="8"><div class="card3 bg-purple" style="margin-right: 36px;"> </div></el-col><el-col :span="8"><div class="card3 bg-purple-light" style="margin-right: 36px;"></div></el-col><el-col :span="8"><div class="card3 bg-purple"></div></el-col></el-row></div><!-- 尾部 --><div class="end"><el-row style="margin-bottom: 0;"><el-col :span="24"><div class="end bg-purple-dark"></div></el-col></el-row></div></div></template>

CSS样式

代码清单 2

* {margin: 0;padding: 0;}.el-row {margin-bottom: 20px;&:last-child {margin-bottom: 0;}}.el-col {border-radius: 4px;}.card{margin-top: 20px;margin-left: 70px;margin-right: 70px;}.double {border-radius: 4px;min-height: 50px;}.card3 {border-radius: 4px;min-height: 490px;}.top, .end {border-radius: 4px;min-height: 50px;}.bg-purple-dark {background: #99a9bf;}.bg-purple {background: #d3dce6;}.bg-purple-light {background: #e5e9f2;}.row-bg {padding: 10px 0;background-color: #f9fafc;}

具体效果:

(一)使用el-container装。el-container 的子元素一般包括el-header、el-aside、el-main、el-footer。同样这些标签里无法使用class类,若要改变样式,要直接使用style要用.el-header这样的样式。

代码清单 1

<template><el-container><!-- 头部 --><el-header>Header</el-header><!-- 中间 --><el-main><el-row><el-col :span="24"><div class="grid-c bg-purple-dark"></div></el-col></el-row><!-- 嵌套 --><el-container> <el-header>头</el-header> <el-main> <el-row> <el-col :span="8"><div class="grid-desCard bg-purple"></div></el-col> <el-col :span="8"><div class="grid-desCard bg-purple-light"></div></el-col> <el-col :span="8"><div class="grid-desCard bg-purple"></div></el-col> </el-row> </el-main></el-container></el-main><!-- 尾部 --><el-footer >Footer</el-footer></el-container></template>

STYLE样式

代码清单 2

.el-header,.el-footer {background-color: #B3C0D1;color: #333;text-align: center;line-height: 60px;}.el-main { background-color: #E9EEF3; color: #333; text-align: center; line-height: 160px; }.grid-c{border-radius: 4px;min-height: 70px;}.grid-desCard{border-radius: 4px;min-height: 416.117px;}.bg-purple-dark {background: #99a9bf;}.bg-purple-light {background: #e5e9f2;}.bg-purple {background: #d3dce6;}

具体效果:

3 结语

本篇文章主要讲的是通过div盒子和el-container两种方式进行网页的简单布局及嵌套功能。同样可以将两种方式的中间部分进行改变,在官网中有许多Layout 布局的样式,可以根据自己想要的效果进行变换。

实习编辑:李欣容

稿件来源:深度学习与文旅应用实验室(DLETA)

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2021-12-04,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 算法与编程之美 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档