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

时间:2018-12-21 20:53:33

标签: css internet-explorer header position sticky

enter image description here我在使用Internet Explorer时将标题和导航放置在所需位置时遇到了问题。它可以与其他浏览器一起正常工作,但不适用于IE。我认为问题在于使用粘性定位,但是我不知道如何使标头与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;
}

1 个答案:

答案 0 :(得分:0)

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

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

或者,您可以更新您的设计,因此它不需要position: sticky