html - margin 哪里去了?

标签 html css

我有以下 html/css 代码:http://jsfiddle.net/J3YZ8/4/

HTML:

<div id="headerDiv">HeaderPanel</div>

<div id="bodyDiv">
    <div id="loginContainer">LoginPanel</div>
    <div id="contentContainer">Content</div>
    <div id="menuContainer">MenuPanel</div>
</div>
<div id="footerDiv">FooterPanel</div>

CSS:

* {
    padding: 0px;
    margin: 0px;
}

html {
    height: 100%;
}

body {
    direction: rtl;
    height: 100%;
    font-family: verdana, arial, helvetica, sans-serif;
    font-size: 75%;
}

#headerDiv {
    height: 20%;
    margin-bottom: 1%;
}

#footerDiv {
    height: 10%;
    margin-top: 1%;
}

#headerDiv,
#footerDiv {
    clear: both;
    background-color: #FF5500;
}

#bodyDiv {
    height: 68%;
    margin: 0% 2%;
}

#loginContainer {
    background: green;
    margin-bottom: 1%;
}

#menuContainer {
    background: blue;
    margin-top: 1%;
}

#loginContainer,
#menuContainer {
    display: inline-block;
    width: 29%;
    margin-left: 1%;
    height: 49%;
}

#contentContainer {
    width: 69%;
    height: 100%;
    background: yellow;
    float: left;
    margin-right: 1%;
}

如果您在浏览器上使用此代码(没有 jsfiddle),您将看到蓝色 div (menuContainer) 和页脚之间没有边距。在 jsfiddle 中,边距不等于黄色 div (contentContainer) 和页脚之间的边距,尽管它应该相同。我该如何解决?

更多详情:
这是来自 jsfiddle 结果的图像:
enter image description here
这是来自全屏结果的图像:
enter image description here

有人知道怎么解决吗?

最佳答案

  1. 我确实看到蓝色面板下方有空白。
  2. html 元素 100% 的高度并不意味着“不高于窗口”。如果您不想滚动页面,您可以在 html 上设置 overflow:hidden。但是你将看不到页脚。

关于html - margin 哪里去了?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8685596/

相关文章:

ipad - 如何让 iPad 在我的移动友好网站上忽略 user-scalable=no?

html - 在另一个页面上重复页脚 html/css,但显示不同?

javascript - 无法将事件绑定(bind)到多个 <select>,只能绑定(bind)第一个子元素

jquery - 使用 Opera 加载 jQuery 后

javascript - 推荐有关现代 CSS 和设计实践的好书/资源

java - 声明 ENTITY 将 nbsp 定义为字符串 "&nbsp;"

javascript - jquery - 更改 html <b> 标签的内容

jquery - 简单的页面淡入

html - Div重叠

javascript - 重新调整 Flash 对象的大小无法正常工作