国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 金坛市| 前郭尔| 宿松县| 南溪县| 铜山县| 山东省| 四子王旗| 惠东县| 墨脱县| 中牟县| 天全县| 麻栗坡县| 山西省| 宁武县| 调兵山市| 咸阳市| 册亨县| 衡东县| 普兰店市| 榆林市| 徐州市| 兴山县| 西宁市| 焦作市| 桂林市| 北辰区| 晋江市| 滕州市| 宁明县| 乡城县| 藁城市| 丰都县| 香格里拉县| 绥化市| 呼伦贝尔市| 武乡县| 嘉定区| 额尔古纳市| 池州市| 尉氏县| 余姚市|