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 中不支持:
- > https://developer.mozilla.org/en-US/docs/Web/CSS/position#Browser_compatibility
- > https://caniuse.com/#search=sticky
要复制粘性的效果,您将不得不使用 js。您可以自己编写或寻找已经存在的“粘性 polyfill”。
或者,您可以更新您的设计,使其不需要position: sticky
。
关于css - 无法在 Internet Explorer 中定位我的标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53890682/