html - div 和页面边之间的空间

标签 html css

我有几个 width :100% 的 div。当我运行代码时,我在 div 和页面两侧(右侧和左侧)之间留有空间。

这是我的 html 代码:

<div id="main_pics" class="container">
<!-- photos here -->

</div>

<div id="other1" class="container">

</div>

<div id="other2" class="container">
</div>

这是我的CSS代码:

#main_pics{
margin-top: 57px;
/*background-color: rgb(224,224,224);*/
/*border: 1px solid black;*/
}

.container{
width: 100%;
height: 500px;
background-color: white;
}

#other1{
background-color: rgb(224,224,224);
width: 100%;
}

#other2{
width: 100%;
background-color:fuchsia;
}

我将 #main_pics 设置为 margin-top: 57px,因为它上面有一个导航栏。

有人知道问题出在哪里吗?

最佳答案

试试这个 CSS:

body, html{
    margin: 0;
    padding: 0;
}

关于html - div 和页面边之间的空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27864273/

相关文章:

javascript - 如何从 HTML 中的颜色选择器中删除 "other..."选项?

html - 如何在 CSS3 的边框中使用渐变?

css - 我的 VideoJS 播放器搞砸了

css - 将 div 粘贴到右下角,但始终位于页脚上方

java - 在 servlet 中使用 JSP 文件中的数据

javascript - 使用 jquery 显示/隐藏时不是预期的 'effect'

html - 仅使用 CSS/HTML 将鼠标悬停在按钮上时显示 div

javascript - 在 div 中禁用文本光标

php - 何时过滤/清理数据 : before database insertion or before display?

css - 理解 dijit css 和样式的逻辑