css - 内部 div 具有 0x0 大小,即使它有内容

标签 css html layout

我的 #main div 没有 heightwidth 尽管其中有内容。我希望 #main div 填充 headerfooter 之间的 100% 空间,以便显示整个页面中 #mainbackground-image(减去 headerfooter)。我无法让 #main 动态填充整个空间(它应该在调整浏览器窗口大小时调整大小)...我该怎么做?

HTML:

<body>
  <div id="page">
    <header id="header">
        <ul>
            <li><a href="#">Item 1</a></li>
            <li><a href="#">Item 2</a></li>
            <li><a href="#">Item 3</a></li>
            <li><a href="#">Item 4</a></li>
            <li><a href="#">Item 5</a></li>
        </ul>
    </header>

    <content id="main">
        <h1>Body</h1>
        <p>Text...</p>
    </content>

    <footer id="footer">
        <ul>
            <li><a href="#">Item 1</a></li>
            <li><a href="#">Item 2</a></li>
            <li><a href="#">Item 3</a></li>
            <li><a href="#">Item 4</a></li>
        </ul>
    </footer>
</div>
</body>

CSS:

#page {
    min-height: 100%;
    height: 100%;
    position: relative;
}

#main {
    padding-bottom: 50px;
    background: url('Background.jpg');
}

#header {
    text-align: center;
    background: #595959;
    font-size: 30px;
    line-height: 60px;
}

#header ul li {
    display: inline-block;
    height: 60px;
    width: 19%;
}

#header ul li:hover, #footer ul li:hover {
    background: #696969;
}

#header ul li a, #footer ul li a {
    display: block;
    text-decoration: none;
    color: #BFBFBF;
}

#footer {
    position: absolute;
    height: 50px;
    width: 100%;
    bottom: 0;
    text-align: center;
    background: #595959;
    font-size: 25px;
    line-height: 50px;
}

#footer ul li {
    display: inline-block;
    height: 50px;
    width: 15%;
}

#footer img {
    margin-right: 10px;
}

最佳答案

关于css - 内部 div 具有 0x0 大小,即使它有内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19605650/

相关文章:

html - 如何调整第 4 个图像列以使其成为响应式图像库

grails - GroovyPagesException:应用布局时出错

html - 始终居中的 Bootstrap 响应式固定宽度 col

javascript - 根据 JQuery 中是否包含 <a> 标记更改 TD 类

jquery - 在 jQuery 中根据 ID 调用函数

javascript - 一个 HTML 页面上的多个表单 : how to restrict tabbing to a single form?

Python tkinter网格布局问题

HTML - 特殊字母加粗/突出显示?

jquery - 显示和隐藏焦点

css - Zurb Foundation 中的重叠 div