html - 整个网页左侧不需要的边距/间隙

标签 html css margin

刚开始制作网站时,整个左侧都有几个像素的边距,但我不明白为什么。

http://jsbin.com/elufob/1/

任何建议将不胜感激

CSS

    html{
    min-width: 100%;
    background-color: #add8e6;
}

.navBar{
    text-align: center;
    background-image: linear-gradient(to bottom, #666666 0%, #000000 60%);
    color: white;
    border-bottom:solid 1px #666;
    top:0;
    height:30px;
    position:fixed;
    width:100%;
    z-index:1000;
}

.leftDiv{
    clear: left;
    text-align: left;
    background-color: blue;
    float: left;
    max-width: 26%;
    display: inline-block;
    margin-right:2%;
    margin-left: 0%;
    margin-top: 2%;
    border: black;
    border-width: 5px;
    border-style: double;
    border-radius: 5px;
}

.middleDiv{
    text-align: center;
    background-color: green;
    max-width: 70%;
    float: right;
    display: inline-block;
    margin-top: 2%;
    MARGIN-BOTTOM: 1%;
    border-style: solid;
    border: black;
    border-width: 5px;
    border-style: double;
    border-radius: 5px;
}

.pageContainer{
    width: 100%;
    min-height: 100%;
    min-width: 100%;
    height: auto !important;
    height: 100%;
    margin: 0 auto -142px;
}

.footer{
    background-image: linear-gradient(to bottom, #666666 0%, #000000 60%);
    color: white;
    border-top:solid 1px #666;
    bottom:0;
    height:15px;
    padding:5px;
    position:fixed;
    width:100%;
    z-index:1000;
}

和 HTML

<html>
<link rel="stylesheet" href="psWebCss">

<header class=navBar>
    <a href="http://www.google.com"><img src="http://library.thinkquest.org/10127/media/examples/Button.gif"></a>
    <a href="http://www.google.com"><img src="http://library.thinkquest.org/10127/media/examples/Button.gif"></a>
    <a href="http://www.google.com"><img src="http://library.thinkquest.org/10127/media/examples/Button.gif"></a>
    <a href="http://www.google.com"><img src="http://library.thinkquest.org/10127/media/examples/Button.gif"></a>


</header>    
<body>
<div class="pageContainer">    
    <div class="leftDiv">          
    </div>   
    <div class="middleDiv"> 
    </div>
</div>
<div class="footer">
   Footer Text
</div>
</body>





</html>

最佳答案

你的 body 标签有 margin: 8px; 只需在你的 css 中添加

body {
    margin: 0;
}

关于html - 整个网页左侧不需要的边距/间隙,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40350654/

相关文章:

css - Magento:将图标添加到您的帐户仪表板中的菜单链接

javascript - 按下按钮后弹出调整大小

css - 有人可以解释这种 css margin 行为吗?

javascript - 带有 CSS Sprite 图像的 jQuery UI 弹跳效果

html - CSS 样式问题 - 滚动

html - CSS、HTML 和 DIV ID

html - 响应式背景图像 div 和固定导航的重叠内容问题

html - 使用 margin 0 auto 居中 div

html - 当页面大小发生变化时,在固定导航栏的中心对齐图像时出现问题

javascript - Facebook 中 URL 发生变化的网页部分更新效果