我试图创建一个包装在其中4个div彼此相邻(两个彼此相邻,下方是剩下的两个)。然而问题是,是否只有第四个正在显现。我试过设置溢出:隐藏,玩具与显示属性,并试图使用float:left和float:right。但迄今为止没有运气。将四个div放在一个包装中,只有一个显示自己
这是我使用的CSS:
html, body{
width: 100%;
height: 100%;
}
#wrapper{
width: 60%;
height: 60%;
top: 20%;
left: 20%;
position: relative;
overflow: hidden;
border: 1px solid #000;
}
#one{
background-color: red;
width: 50%;
position: absolute;
height: 50%;
}
#two{
background-color: green;
width: 50%;
position: absolute;
height: 50%;
}
#three{
background-color:blue;
width: 50%;
position: absolute;
height: 50%;
}
#four{
background-color: yellow;
width: 50%;
position: absolute;
height: 50%;
}
,这是html代码与它去:
<html><head>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head><body>
<div id="wrapper">
<div id="one">a</div>
<div id="two">b</div>
<div id="three">c</div>
<div id="four">d</div>
</div>
</body></html>
谁能弄清楚为什么黄(四)个DIV是唯一一个显示自己,即使我让它正确地浮动和其他人离开? (除此之外,我还想知道为什么滚动条出现的原因是宽度:100%,身高部分为100%)。
到底会发生什么,然后,如果它从流去掉? – Gooey 2012-07-24 14:59:26
它们位于具有位置集的第一个父代的左上角。 – j08691 2012-07-24 15:00:07