Div不是浏览器宽度的100% [英] Div not 100% width of browser
本文介绍了Div不是浏览器宽度的100%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的div不会拉伸浏览器的整个宽度,它的两端都短了约10像素.
My div will not stretch the full width of the browser, it stops short on both ends by about 10px.
.header {
position: relative;
background-color: #088ed7;
width: auto;
height: 20px;
}
<div class="header">...</div>
我已经尝试了 auto
和 100%
,但仍然得到了相同的结果.
I've tried both auto
and 100%
but still get the same outcome.
推荐答案
可能是页面的页边距和/或填充.
It's likely the page's margin and/or padding.
添加:
html, body {
padding: 0;
margin: 0;
}
.header {
margin: 0;
}
html,
body {
padding: 0;
margin: 0;
}
.header {
margin: 0;
position: relative;
background-color: #088ed7;
width: auto;
height: 20px;
}
<div class="header">...</div>
这篇关于Div不是浏览器宽度的100%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文