html - 当我有一个“位置:固定;”时该怎么办?标题和图像滑块“位置:相对;” 就在标题下方?
问题描述
我使用 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. */
}
推荐阅读
- reactjs - ReactJS 中的循环组件
- varnish - 如何设置清漆后端连接空闲超时?
- sql - 如何编写 SQL 以使用 group by 函数从多行中提取最新的非空数据?
- php - 表格未显示动态值
- cmake - 如何为 yocto poky 添加库?
- jwt - 无法使用从 AzureKeyVault 读取的证书写入 JWTToken
- events - 如何将点击/点击事件添加到 AmCharts 4 Range?(ValueAxisDataItem)
- rust - rust 寿命问题,为什么第一次调用没有编译错误?
- ansible - 如何使用 Ansible 获取主机 IP 和主机名
- elasticsearch - 如何过滤top hits聚合结果