css屬性改變?nèi)萜鞯某叽?/h4>
- 可以改變元素占據(jù)空間(如影響父元素的高度(當(dāng)父元素不定高的情況下))
<html>
<style>
/*此處省略reset.css*/
.box1{background:gray;}
/*設(shè)置vertical-align:bottom 是為了解決img與父級元素之間留有空白的故障*/
.box2{height:200px;width:200px;background:gold;vertical-align:bottom;}
</style>
<body>
<div class="box1">

</div>
</body>
</html>
margin負(fù)值的應(yīng)用
-
margin負(fù)值下的兩端對齊(margin改變元素尺寸)
圖片.png
- margin負(fù)值下的等高布局(margin改變元素占據(jù)空間)
通過設(shè)置margin-bottom為負(fù)值,padding-bottom為正值來實(shí)現(xiàn)。父元素需overflow:hidden;
- margin負(fù)值下的兩欄自適應(yīng)布局
<html>
<style>
/*此處省略reset.css*/
.box1{background:gray;}
/*設(shè)置vertical-align:bottom 是為了解決img與父級元素之間留有空白的故障*/
.box2{height:200px;width:200px;background:gold;vertical-align:bottom;}
</style>
<body>
<div class="box1">

</div>
</body>
</html>
margin負(fù)值下的兩端對齊(margin改變元素尺寸)
圖片.png
通過設(shè)置margin-bottom為負(fù)值,padding-bottom為正值來實(shí)現(xiàn)。父元素需overflow:hidden;