css - 无法在 Internet Explorer 中定位我的标题

标签 css internet-explorer header position sticky

enter image description here在使用 Internet Explorer 时,我在将标题和导航放置在我想要的位置时遇到了问题。它适用于其他浏览器,但不适用于 IE。我认为问题在于使用粘性定位,但我不知道如何使我的 header 与 Internet Explorer 兼容。我已经包含了相关代码和标题在 IE 中的外观图片。导航应该在山脉图片的底部,而不是页面的左上角。

header {
   position: absolute;
   position: sticky;
   top: 0;
   clear: both;
   border-bottom: 2px solid black;
   border-top: 2px solid black;
   margin: 0px;
   padding: 0px;
   background-color: #2E2D2D;
   z-index: 1;
}

nav {
   width: 800px;
   height: 70px;
   margin-left: auto;
   margin-right: auto;
   color: #fff;
}

最佳答案

快速搜索显示它在 IE 中不支持:

要复制粘性的效果,您将不得不使用 js。您可以自己编写或寻找已经存在的“粘性 polyfill”。

或者,您可以更新您的设计,使其不需要position: sticky

关于css - 无法在 Internet Explorer 中定位我的标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53890682/

相关文章:

internet-explorer - CSS 中的下拉菜单在 IE9 中显示为透明

c++ - 文件包含错误 (C++) : undefined reference to ______

java - 如何更改 JavaFX 中的突出显示颜色?

CSS - 填充 float 元素旁边的剩余宽度并防止内容掉落到 float 元素下方?

html - 如何只为所有版本的ie添加margin-top样式

html - 图例中的 header 有效吗? <图例><h1>标题</h1></图例>

c++ - 使用命名空间标准

javascript - Jquery attr() - Mozilla 在设计方面表现不同(不同的字体系列或字体大小?)

javascript - 水平滚动到,用wordpress acf

internet-explorer - 浏览器不会向服务器请求最新的 PDF