Jquery 修复了头透明背景问题?
我试图将z-index放在我的头类中,但仍然不起作用。当我向下滚动时,关于位置和后续滚动的一切都很好,但标题的背景变得透明 我的cssJquery 修复了头透明背景问题?,jquery,css,Jquery,Css,我试图将z-index放在我的头类中,但仍然不起作用。当我向下滚动时,关于位置和后续滚动的一切都很好,但标题的背景变得透明 我的css .header { background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.7) 10%, rgba(0, 0, 0, 0)); background-position: fixed; overflow: hidden; padding: 0 4%; z-i
.header {
background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.7) 10%, rgba(0, 0, 0, 0));
background-position: fixed;
overflow: hidden;
padding: 0 4%;
z-index: 10000;
height: 70px;
}
.fixed {
position: fixed;
top: 0;
left: 0;
width: 100%;
animation: smoothScroll 1s forwards;
}
@keyframes smoothScroll {
0% {
transform: translateY(-70px);
}
100% {
transform: translateY(0px);
}
}
我的js
我修复了在“.fixed”类中添加另一个背景的问题。所以现在没事了。你能解释得更清楚一点吗?现在还不清楚你想要什么,你遇到了什么问题。你能发布你的html吗?
if ($('#wpadminbar')[0])
$('.header').css('top', '32px')
$(window).scroll(function() {
var sticky = $('.header'),
scroll = $(window).scrollTop();
if (scroll >= 50) {
sticky.addClass('fixed');
sticky.css("background-position","fixed");
body.css("padding-top", "70px");
} else {
sticky.removeClass('fixed');
body.css("padding-top", "none");
}
});