【问题标题】:the div background appears white with zoomingdiv 背景在缩放时显示为白色
【发布时间】:2014-04-08 09:32:20
【问题描述】:

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

我尝试放大 Facebook 网站,但未出现此问题。

这张图片可以让问题更清楚。

那么问题出在哪里?

HTML 标题 css

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

【问题讨论】:

  • 请向我们展示您的代码。
  • 或者更好的是,一个 JSFiddle
  • 我刚刚添加了标头代码

标签: html css background


【解决方案1】:

如果窗口底部有水平滚动条时出现问题

那么不要使用 width:100% 。无论如何,这是块元素的默认值,对于保留在流中的元素是无用的;

width:100% 将缩小其在屏幕宽度上的布局(或父级,如果它在 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

【讨论】:

  • 谢谢,display: table 解决问题。
  • @MohamedAref,如果这个答案对你有帮助,那就接受吧。这样你就可以给 Gcyrillus 学分,社区的其他人就不会再被这个问题困扰了
【解决方案2】:

您的宽度似乎是固定的。试试:width:100% 在你的 div 上

【讨论】:

    【解决方案3】:

    需要将宽度设置为菜单的 100%

    【讨论】:

    • 每个父元素取width:100%
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-11-27
    • 2015-08-09
    • 2010-12-19
    • 1970-01-01
    • 1970-01-01
    • 2015-03-27
    • 1970-01-01
    相关资源
    最近更新 更多