全屏宽度div区域 [英] Full screen width div area
问题描述
创建div的最佳方法是什么,无论分辨率如何,该div都将占据屏幕的整个宽度?我正在尝试添加一个div的顶部"栏和底部页脚"区域,这些区域具有黑色背景和边框,而这些边框我将使用小图像创建并重复.出于某种原因,我的尝试导致div顶部和侧面的狭小空间?
What's the best approach to creating a div that will take the full width of the screen, no matter what resolution? I'm trying to add a 'top' bar and bottom 'footer' area with divs that have a black background and styled border that I'd create with a small image and repeat. For some reason my attempts are leading to small spaces on the top and sides of the div?
我的标记类似于:
<div id="top">
Top bar stuff
</div>
<div id="pagewrap">
All the page content
</div>
CSS
#top {
width: 100%;
margin: 0;
padding: 0;
background-color:#000
推荐答案
只需使用 top:0;
和 left:0;
,您还可以消除填充:0
.除top以外,请勿对其他div使用 top:0;
,对其他div使用 left:0;
来消除剩余空间.
Just use top:0;
and left: 0;
and you can also eliminate padding: 0
. Don't use top: 0;
for other div except top, use left: 0;
for other div for eliminate the left space.
#top {
width: 100%;
margin: 0;
padding: 0;
background-color:#000
top: 0;
left: 0;
}
这篇关于全屏宽度div区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!