html - Div 背景没有绘制整个 Div

标签 html css 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 实现,因此要求当您缩小页脚时,它会粘在 屏幕的底部/视口(viewport)

关于如何在 IE11 上解决这个问题而不影响其他浏览器有什么想法吗?

如果可能,请 fork codesandbox.io 并将包含您的解决方案的链接粘贴到此处。

谢谢!

最佳答案

应用 flex: 0 0 auto; 到你的页脚。

enter image description here

关于html - Div 背景没有绘制整个 Div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54577170/

相关文章:

php - HTML 字符按字面翻译

javascript - 在 2 个不同区域重复循环时该怎么办

html - 当我将文档类型添加到我的网页时,图像不加载

jQuery 在选择更改时提交表单

html - 如何并排移动图像?

css - 如果我想要的只是来自 Angular Material 的 flexbox 类,那么最好的选择是什么?

html - 为什么 div 中的文本会导致此布局中断?

xhtml - 为什么 XHTML1.1 的日期*早于* XHTML1.0 ?现在首选的 XHTML 是什么?

javascript - 无法使用 JavaScript 更改窗口对象的属性

jquery - 将 div 放在广告上方而不是下方