在這個(gè)代碼中為什么添上overflow:hidden后wrap就有高度了?
11-8這一張的代碼.因?yàn)槿∠羲蜎](méi)有了自帶的green背景了
代碼如下:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>columns</title>
<link href="style.css" rel="stylesheet" type="text/css">
<style>
.wrapper{
? width: 100%;
? background: green;
? max-width: 980px;
? /*overflow: hidden;*/
? margin-left: auto;
? margin-right: auto;
? border:5px solid red;
}
.left {
? float: left;
? width: 20%;
? background: orange;
? min-height: 100px;
}
.content {
? float: right;
? width: 78%;
? background: blue;
? min-height: 100px;
}
@media (max-width: 480px) {
? .wrapper {
? ? min-width: 320px;
? ? width: 98%;
? ? margin-left: 1%;
? ? margin-right: 1%;
? }
? .left {
? ? float: none;
? ? width: 100%;
? }
? .content{
? ? float: none;
? ? width: 100%;
? }
}
</style>
</head>
<body>
<div class="wrapper">
? <div class="left"></div>
? <div class="content"></div>
</div>
</body>
</html>
2022-03-25
不理解就先把步驟硬記住,慢慢就理解了我就是這么做的你估計(jì)輸入錯(cuò)了??<span></span>中的內(nèi)容不在<div></div>標(biāo)簽內(nèi),而是在它之外
2017-01-13
沒(méi)有overflow的時(shí)候wrapper因?yàn)槔锩娴脑馗?dòng)沒(méi)有消除,不會(huì)占據(jù)高度,overflow不僅可以隱藏溢出,還可以消除浮動(dòng)。