css - 如何让我的 <div> 拉伸(stretch)到屏幕的整个宽度?我试过宽度 100%

标签 css html width fullscreen

我想做一个<div>它的宽度将延伸到整个屏幕。现在我在 CSS 中有这个:

#spacer3 {

width:100%;
height:300px;

}

所以我相信它是有效的。但在我的网站上,div 并没有完全拉伸(stretch),每边大约有 5px。有帮助吗?

Here is a link to the site for a example 我遇到问题的 div 具有黑色(左右)背景并且其中有图像。

提前感谢所有帮助!

最佳答案

您应该删除 body 的边距(或插入内容的任何其他元素),如下所示:

body {
    margin: 0;
}

关于css - 如何让我的 <div> 拉伸(stretch)到屏幕的整个宽度?我试过宽度 100%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15671378/

相关文章:

html - 自定义菜单包含语言和带有 Bootstrap 的菜单

html - Mac Safari 上的 CSS 列表项额外填充

html - 完美的图像容器 : Centered, 宽高比,收缩和增长以适合

css - 如何调整li内div内标签的宽度?

css - 如何在全日历中使用边框间距

css - 使用混合的动态 margin 值

jquery - 使用 Jquery Cycle 暂停/恢复动画

javascript - JS : Drag and Drop img disappears if dropped on another img

javascript - scriptlet 的文本框值

html - 固定高度的全宽图像