当我有一个“位置:固定”时该怎么办标头和图片滑块“ position:relative;”在标题下方?

时间:2018-12-22 04:38:19

标签: html css

我已经使用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;}.....}  

1 个答案:

答案 0 :(得分:0)

使用z-index选项将标题始终保持在顶部,如下所示:

.header {
  z-index: 2; /* This value is sufficient if the other content does not have a z-index value. */
}
相关问题