html - html div 的问题不包含它们应该包含的内容

标签 html css position css-position

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/

相关文章:

javascript - 按钮在改变位置时不起作用

HTML/CSS - 减小窗口大小但导航菜单停留在屏幕右上角

javascript - 单个页面中的多个切换菜单不起作用

css - 将行内 block DIV 对齐到容器元素的顶部

javascript - 使用 jQuery 创建并排幻灯片的问题

表单提交后 jQuery.hide() 不工作

html - 在输入上设置最小值和最大值会删除间距吗?

html - 我无法让特定的 div 停止滚动页面(我希望它留在一个地方)

html - 哪些浏览器支持input属性-multiple

javascript - 导航栏加载延迟