我使用 CSS 属性制作了一个标题,position: fixed;
在标题部分的正下方,我包含一个带有 CSS 属性的图像滑块,position: relative;
.我的问题是,向下滚动页面时,图像往往会干扰标题部分。请告诉我该怎么做?
.header{position: fixed; background-color: black;}
.sliderbox{position: relative; width: 1200px; animation-duration: 20s; animation-name: slideranimation;}
@keyframes slideranimation{0%{left: 0px;} 20%{left:0px;}.....}
使用z-index
选项将标头始终保持在顶部,如下所示:
.header {
z-index: 2; /* This value is sufficient if the other content does not have a z-index value. */
}