div背景显示为白色并带有缩放功能

时间:2014-04-08 09:32:21

标签: html css background

我有缩放问题,如果任何div有背景颜色/边框,当我放大时它会显示为白色。

我尝试放大Facebook网站,但这个问题没有出现。

此图片可以更清晰地解决问题。

enter image description here

那么问题是什么?

HTML标头css

header {
  border-bottom: 1px solid #d6d6d6;
  width: 100%;
  padding-bottom: 10px;
  background-color: #BF0404;
  color: white;
  background-position:bottom;
}

3 个答案:

答案 0 :(得分:3)

如果您的窗口底部有水平滚动条,则显示问题

然后不要使用width:100%。无论如何,这是块元素的defaut值,对流中保留的元素没用;

width:100%会缩小它在screenwidth上的布局(如果它在CSS中有有效宽度,则为父级)。

要让标题超出父宽度,请为其指定一个允许其自然展开(或缩小)的布局。

header {
  min-width:100%;/* as a block element , it should cover all width avalaible, make sure it does */
  display:table;/* will expand , so background will too*/
}

<强> DEMO

答案 1 :(得分:0)

看来你有一个固定的宽度。在你的div上尝试:width:100%

答案 2 :(得分:0)

必须将宽度设置为菜单的100%