【发布时间】:2020-09-18 06:24:36
【问题描述】:
美好的一天!我是新来的!现在,对不起愚蠢:-)
功能:向下滚动时标题变为可见。滚动到顶部时隐藏。代码有效,但我无法使用 removeClass 进行软淡出。 有人可以帮我吗?
<script type="text/javascript">
jQuery( document ).ready(function() {
var header_fixed = jQuery(".header-fixed")
jQuery( header_fixed ).wrap( "<div class='header-f-wrapper'></div>" );
var header_f_wrapper = jQuery (".header-f-wrapper");
var height = jQuery(".et-l--header").height()+(20);
jQuery(window).scroll(function(){
if(jQuery(this).scrollTop()>height){
header_f_wrapper.addClass("header-show");
}
else{
header_f_wrapper.removeClass("header-show");
}
})
})
</script>
<style>
@keyframes fadein {
from { opacity: 0; }
to { opacity: 1; }
}
.header-f-wrapper {
display:none;
}
.header-f-wrapper {
z-index: 999; /* display at the top */
position: fixed;
width:100%;
top: 0;
-webkit-animation: fadein 0.9s ease-in;
-moz-animation: fadein 0.9s ease-in;
animation: fadein 0.9s ease-in;
}
.header-f-wrapper.header-show {
display:block;
}}
}}
</style>
【问题讨论】: