http://i.stack.imgur.com/zg35O.png
我的 div id="topcol"显示的区域比应有的要小得多。它应该包括 4 个“选项”。选项是相对的,因此选项标题可以是绝对的,并覆盖每个选项中的图像。
我意识到这可能是一个非常基本的错误,但我已经为此苦苦挣扎了几个小时
html:
<div id="cols">
<div id="topcol">
<h1 id="content_title">BrightWell Smart Page Services</h1>
<div class="options" id="op1" name="General Links"><img class="optionicons" src="generalLinks.jpg"/><span class="optiontitle">General Links</span></div>
<div class="options" id="op2" name="Useful Online Tools"><img class="optionicons" src="Toolbox.jpg"/><span class="optiontitle">Useful Online Tools</span></div>
<div class="options" id="op3" name="IT Links"><img class="optionicons" src="ITSupport.jpg"/><span class="optiontitle">IT Links</span></div>
<div class="options" id="op4" name="Utility"><img class="optionicons" src="utility.jpg"/><span class="optiontitle">Utility</span></div>
</div>
<div id="botcol">
<div id="infopanel">
</div>
</div>
</div>
css:
html {
font-family: 'FuturaW01-LightCondense 774878',Helvetica,Arial,sans-serif;
font-weight: lighter;
}
#cols {
z-index:1;
position: absolute;
top:0;
left:0;
height:100%;
width:100%;
}
#topcol {
height:auto;
width:100%;
}
#botcol {
width:100%;
}
#content_title {
font-size: 32px;
line-height: 1.2;
}
.options {
margin-left:2.5%;
margin-right:2.5%;
height:30%;
width:19%;
float:left;
border: black solid 1px;
position:relative;
}
#op1{
}
#op2{
}
#op3{
float:right;
}
#op4{
float:right;
}
.optiontitle {
color: blue;
position:absolute;
top:0;
left:0;
text-align:center;
font-size:200%;
width:100%;
}
.optionicons {
height:100%;
width:100%;
}
#infopanel {
width:100%;
height:100%;
}
最佳答案
由于您 float 了子 div,因此它们从正常流中移除并且父 (topcol) 崩溃,就好像它们不存在一样。您可以将 overflow:auto
添加到您的 #topcol 规则中以恢复您想要的行为。
关于html - html div 的问题不包含它们应该包含的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29304031/