Div的背景并未画出整个Div

时间:2019-02-07 15:50:23

标签: html css html5 css3 doctype

我有以下代码:

https://codesandbox.io/s/yv983q28xx

来源:

<html>
<head>
<title>Testing on IE 11</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body {
  margin: 0;
  padding: 0;
  background-color: #d6ffbb;
}
.page-container {
  padding: 10px;
}
footer {
  text-align: justify;
  font-family: Arial;
  font-size: 14px;
  letter-spacing: normal;
  padding: 20px;
  color: #fff;
  background: url("https://i.ibb.co/hYXDL2N/pattern-dark.jpg") top center
    repeat;
}
/* BEGIN OF CODE BLOCK FOR STICKY FOOTER */
body {
  display: -webkit-box !important;
  display: -ms-flexbox !important;
  display: flex !important;
  height: 100%;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
}
.page-container {
  -webkit-box-flex: 1;
  -ms-flex: 1 0 auto;
  flex: 1 0 auto;
}
/* END OF CODE BLOCK FOR STICKY FOOTER */
</style>
</head>

<body>
  <div class="page-container">
    hello world<br />
    hello world<br />
    hello world<br />
    hello world<br />
    hello world<br />
    hello world<br />
    hello world<br />
    hello world<br />
    hello world<br />
    hello world<br />
    hello world<br />
    hello world<br />
    hello world<br />
    hello world<br />
    hello world<br />
  </div>
  <footer>
    <p>
      Lorem Ipsum is simply dummy text of the printing and typesetting
      industry. Lorem Ipsum has been the industry's standard dummy text ever
      since the 1500s, when an unknown printer took a galley of type and
      scrambled it to make a type specimen book. It has survived not only five
      centuries, but also the leap into electronic typesetting, remaining
      essentially unchanged. It was popularised in the 1960s with the release
      of Letraset sheets containing Lorem Ipsum passages, and more recently
      with desktop publishing software like Aldus PageMaker including versions
      of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and
      typesetting industry. Lorem Ipsum has been the industry's standard dummy
      text ever since the 1500s, when an unknown printer took a galley of type
      and scrambled it to make a type specimen book. It has survived not only
      five centuries, but also the leap into electronic typesetting, remaining
      essentially unchanged. It was popularised in the 1960s with the release
      of Letraset sheets containing Lorem Ipsum passages, and more recently
      with desktop publishing software like Aldus PageMaker including versions
      of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and
      typesetting industry. Lorem Ipsum has been the industry's standard dummy
      text ever since the 1500s, when an unknown printer took a galley of type
      and scrambled it to make a type specimen book. It has survived not only
      five centuries, but also the leap into electronic typesetting, remaining
      essentially unchanged. It was popularised in the 1960s with the release
      of Letraset sheets containing Lorem Ipsum passages, and more recently
      with desktop publishing software like Aldus PageMaker including versions
      of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and
      typesetting industry.
    </p>
    <p>
      Lorem Ipsum is simply dummy text of the printing and typesetting
      industry. Lorem Ipsum has been the industry's standard dummy text ever
      since the 1500s, when an unknown printer took a galley of type and
      scrambled it to make a type specimen book. It has survived not only five
      centuries, but also the leap into electronic typesetting, remaining
      essentially unchanged. It was popularised in the 1960s with the release
      of Letraset sheets containing Lorem Ipsum passages, and more recently
      with desktop publishing software like Aldus PageMaker including versions
      of Lorem Ipsum. Lorem Ipsum is simply dummy text of the printing and
      typesetting industry. Lorem Ipsum has been the industry's standard dummy
      text ever since the 1500s, when an unknown printer took a galley of type
      and scrambled it to make a type specimen book. It has survived not only
      five centuries, but also the leap into electronic typesetting, remaining
      essentially unchanged. It was popularised in the 1960s with the release
      of Letraset sheets containing Lorem Ipsum passages, and more recently
      with desktop publishing software like Aldus PageMaker including versions
      of Lorem Ipsum.
    </p>
  </footer>
</body>
</html>

演示: https://yv983q28xx.codesandbox.io/

此代码可以在{{ChromeFirefoxEdge}上正常工作。

但是在IE11上运行时,我会得到以下行为:

滚动到顶部scrolled to top

滚动到底部(绘画直到上一张图像的结尾): scrolled to bottom

如您所见,当滚动到底部时,div背景不会绘制整个div。

重要提示::这是sticky-footer的实现,因此要求缩小时,页脚必须粘在screen / viewport的底部。

关于如何在IE11上解决此问题而不影响其他浏览器的想法?

如果可能的话,请分叉codesandbox.io并将链接和解决方案粘贴到此处。

谢谢!

2 个答案:

答案 0 :(得分:1)

flex: 0 0 auto;应用于页脚。

enter image description here

答案 1 :(得分:-2)

尝试为页脚提供一个ID,并在其中添加此代码段

background-attachment: fixed;
background-position: center center;
background-size: cover;