【问题标题】:Responsive Background CSS Landing响应式背景 CSS 着陆
【发布时间】:2019-03-18 03:40:56
【问题描述】:

下午好 试图在我的着陆时制作响应式背景,但由于某种原因我不能 我试图使用 height: auto, height: 100% 和 margin: 0 auto;高度 100% 有效,但它没有覆盖到我的屏幕下方,我拥有它超过了我的需要。 这是我的代码:

    .crossfade > figure {
  animation: imageAnimation 48s linear infinite 0s;
  backface-visibility: hidden;
  background-size: cover;
  background-position: center center;
  height: 470px;
  left: 0px;
  opacity: 0;
  position: absolute;
  top: 189px;
  width: 100%;
  background-color: rgba(0,0,0,.3);
  background-blend-mode: darken;
  z-index: 0;
}

只有一件事对我有用,那就是:

height: calc(100vh - 189px);

189px 它从我的标题菜单中缩进,但是我有什么方法可以让它在没有 calc 的情况下工作? 希望你明白我的意思 谢谢

【问题讨论】:

  • 添加您的 html 代码。
  • 这里是网页daotech.org

标签: html css background frontend responsive


【解决方案1】:

试试这个

.crossfade > figure {
  animation: imageAnimation 48s linear infinite 0s;
  background-size: cover;
  background-position: center center;
  width: 100%;
  height: 100vh;
  position: absolute;
  top: 0;
  left:0;
  right:0;
  bottom:0;
  background-color: rgba(0,0,0,.3);
  z-index: 0;
}

【讨论】:

  • 这对我有帮助,但背景覆盖了我网页顶部的菜单
  • 所以尝试使用 z-index
【解决方案2】:

尝试类似:

.crossfade > figure { 
  animation: imageAnimation 48s linear infinite 0s; 
  background-size: cover; 
  background-position: center center; 
  width: 100%; 
  height: 100vh; 
  position: absolute; 
  top: 0; 
  left:0; 
  right:0; 
  bottom:0; 
  background-color: rgba(0,0,0,.3); 
  z-index: 0; 
}

#menu-contact-us { 
  background: #5D5D5D; 
  height: 124px; 
  color: #ffffff; 
  width: 100%; 
  position: relative; 
  z-index: 1; 
} 

我能够在您发布的链接上全屏显示图像

【讨论】:

  • 感谢您的帮助,但我不需要固定背景,它必须只是响应式的,但是当您向下滑动时,它会停留在他的位置。你可以在这里查看例如citelectronics.com,但我很难通过网页顶部的菜单来做到这一点:(
  • 我更新了代码以使用 position: absolute 并在菜单上使用 z-index 以使其覆盖图像,您可能也需要在其他元素上使用 z-index
猜你喜欢
  • 1970-01-01
  • 2012-09-18
  • 2015-08-04
  • 1970-01-01
  • 1970-01-01
  • 2018-08-12
相关资源
最近更新 更多