国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > CSS > 正文

css等高布局常用幾種方式

2024-07-11 08:33:21
字體:
來源:轉載
供稿:網友

等高布局的方式

指在同一個父容器中,子元素高度相等的布局.

從等高布局實現(xiàn)方式來說,又分為兩類

偽等高

子元素高度差依然存在,只是視覺上給人感覺就是等高.

真等高

子元素高度相等

先來看看偽等高實現(xiàn)方式

通過負margin和Padding實現(xiàn)

真等高實現(xiàn)方式

table
absoult
flex
grid
js

偽等高之-負margin和padding

主要利用負margin來實現(xiàn), 具體 負margin實現(xiàn)可以參考下這篇文章


<div class="layout parent">
<div class="left"><p>left</p></div>
<div class="center">
<p>我是中間部分的內容</p>
<p>我是中間部分的內容</p>
<p>我是中間部分的內容</p>
<p>我是中間部分的內容</p>
</div>
<div class="right"><p>right</p></div>
<div style="clear: both;">11111111111</div>
</div>


.parent{
position: relative;
overflow:hidden;
color: #efefef;
}
.center,
.left,
.right {
box-sizing: border-box;
float: left;
}
.center {
background-color: #2ECC71;
width: 60%;
}

.left {
width: 20%;
background-color: #1ABC9C;
}
.right {
width: 20%;
background-color: #3498DB;
}
.left,
.right,
.center {
margin-bottom: -99999px;
padding-bottom: 99999px;
}

真實等高之 – table布局


<div class="layout parent">
<div class="left"><p>left</p></div>
<div class="center">
<p>我是中間部分的內容</p>
<p>我是中間部分的內容</p>
<p>我是中間部分的內容</p>
<p>我是中間部分的內容</p>
</div>
<div class="right"><p>right</p></div>
<div style="clear: both;">11111111111</div>
</div>


.parent{
position: relative;
display: table;
color: #efefef;
}
.center,
.left,
.right {
box-sizing: border-box;
display: table-cell
}
.center {
background-color: #2ECC71;
width: 60%;
}

.left {
width: 20%;
background-color: #1ABC9C;
}
.right {
width: 20%;
background-color: #3498DB;
}

真實等高之 – absolute

            
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 汕尾市| 高阳县| 萍乡市| 涡阳县| 黄陵县| 平顺县| 灵丘县| 玉树县| 昭觉县| 儋州市| 黄冈市| 哈密市| 孝义市| 封开县| 姜堰市| 英吉沙县| 海阳市| 辉县市| 会宁县| 元谋县| 云安县| 嵊泗县| 安徽省| 伊宁县| 祁门县| 鄂托克前旗| 贡嘎县| 马关县| 扶余县| 班戈县| 吉水县| 巫山县| 屯门区| 石首市| 丹凤县| 乐陵市| 贡嘎县| 镶黄旗| 阳原县| 堆龙德庆县| 贵州省|