【问题标题】:Background image covered up when scroll to the bottom滚动到底部时背景图像被遮盖
【发布时间】:2017-12-24 14:02:46
【问题描述】:

当您一直滚动到底部时,背景图像被白色区域覆盖。似乎无法弄清楚它是什么。玩过每个选择器和 HTML。非常感谢帮助。请点击链接转到代码可见的 CodePen。

https://codepen.io/siamazing/pen/QaGdWq

html, body{
  height: 100%;
  }

#body { 
            background-image: url(https://images.pexels.com/photos/267278/pexels-photo-267278.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb) ;
            background-position: center center;
            background-repeat:  no-repeat;
            background-attachment: fixed;
            background-size:  cover;
            background-color: #999;
      height: 100%;
      font-size: 15px;}

.container-fluid {
  padding-top: 20px; 
  padding-left: 40px;
  padding-right: 40px;
  height: 100%;}

h2 {
  padding-left: 20px; 
  font-family: 'pacifico';
  font-size: 22px;
  color: #72777f;
  }

header {
  text-align: center; 
  font-family: 'pacifico'; 
  }

article {
  font-family: 'raleway'; 
  background-color:rgba(255,255,255,.4);   
  color: #303338;
  padding: 10px;
  margin-top: 20px;
  margin-left: 30px;} 

【问题讨论】:

    标签: html css


    【解决方案1】:

    从#body 中删除height:100%

    https://codepen.io/mirohristov/pen/MrbmWj

    【讨论】:

      【解决方案2】:

      查看 Miro 的回答,但这里有一些故障排除建议。

      我添加了 * { outline: 1px dashed red; } 并看到了这个:

      这使得找到罪魁祸首元素变得更容易 - #body 并删除 height:100%;规则。

      【讨论】:

      • 非常感谢。我看到了箭头 - 白色部分是哪个元素?我删除了它并且它有效,但试图了解它的原因。
      • 通过将高度设置为 100% 而不是将其保留为默认值 height: auto,您是在告诉它将自身限制为父元素的 100%。在问题的代码笔中,父级是高度为 100% 的 .container-fluid,然后是高度为 100% 的 body 元素。所有这些都在 iframe 中呈现,该 iframe 具有影响所有这些孩子的有限高度。保留 100% 的高度,除非您通过限制其父元素的高度来故意限制元素的高度,否则您将是金色的!
      猜你喜欢
      • 1970-01-01
      • 2021-10-21
      • 1970-01-01
      • 2015-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多