CSS 布局相关
实现 3 栏垂直布局,并且指定顺序加载
元素 | 方向 | 高度 | 优先级 |
---|---|---|---|
div1 | 底部 | 200px | 1 |
div2 | 中部 | auto | 2 |
div3 | 顶部 | 100px | 3 |
效果
思路 1 父相子绝
父元素使用相对定位,子元素使用绝对定位。
通过 top
、bottom
属性调整位置。
代码
div1
div2
div3
body {
margin: 0;
}
html, body, .wrapper {
height: 100%;
}
.wrapper {
width: 50px;
position: relative;
}
.wrapper > div {
width: 100%;
}
.div1 {
height: 200px;
background-color: aqua;
position: absolute;
bottom: 0;
}
.div2 {
background-color: burlywood;
position: absolute;
top: 100px;
bottom: 200px;
}
.div3 {
height: 100px;
background-color: beige;
position: absolute;
top: 0;
}
原文:https://www.cnblogs.com/pooc/p/14953697.html