首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Chrome 77上高度似乎不能正常工作

在Chrome 77上高度似乎不能正常工作
EN

Stack Overflow用户
提问于 2019-09-28 15:27:51
回答 1查看 78关注 0票数 1

我有一个页面,可以很好地使用Firefox,但不能使用Chrome77。

代码语言:javascript
复制
#container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  height: 100px;
  display: block;
  background-image: linear-gradient(lightblue, rgb(61, 133, 214));
}

#main-section {
  flex-grow: 1;
  background: url("https://picsum.photos/id/15/1000/1000");/* any image you want */
  background-repeat: no-repeat;
  background-size: cover;
}

#main-section-background {
  min-height: 100%;
  height: auto !important;
  background-color: #ffffff;
  opacity: 0.9;
}

.main-content {
  min-height: 100%;
  height: auto !important;
  display: flex;
  justify-content: space-evenly;
}

footer {
  height: 100px;
  background-image: linear-gradient(lightblue, rgb(61, 133, 214));
}
代码语言:javascript
复制
<div id="container">
  <header>
  </header>

  <section id="main-section">
    <div id="main-section-background">
      <div class="main-content">
      </div>
    </div>
  </section>

  <footer>
  </footer>
</div>

背景图像不透明在Firefox中工作得很好。使用chrome时,height和min-height属性没有任何影响,并且不透明度不可见。我尝试了几种方法来强制内容的高度,但看起来Chrome只在实际的HTML内容上应用了不透明度(为了清楚起见,这里没有提到)。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-09-28 15:53:00

您可以优化代码,只保留应用了多个背景的main-section

代码语言:javascript
复制
#container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  height: 100px;
  display: block;
  background-image: linear-gradient(lightblue, rgb(61, 133, 214));
}

#main-section {
  flex-grow: 1;
  background: 
    linear-gradient(rgba(255,255,255,0.9),rgba(255,255,255,0.9)),
    url("https://picsum.photos/id/15/1000/1000");/* any image you want */
  background-repeat: no-repeat;
  background-size: cover;
  display: flex;
  justify-content: space-evenly;
}

footer {
  height: 100px;
  background-image: linear-gradient(lightblue, rgb(61, 133, 214));
}

body {
 margin:0;
}
代码语言:javascript
复制
<div id="container">
  <header>
  </header>

  <section id="main-section">
    
  </section>

  <footer>
  </footer>
</div>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58144268

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档