在滚动功能中添加淡入/淡出



谁能帮我在下面的代码中添加适当的淡入淡出?我缺少一些东西。我正在使用这个onscroll在页面顶部获取div,并在滚动时将其用作修复菜单。

<script>
var windowWidth = $(window ).width();
if(windowWidth>1580){
$(document).ready(function(){
    document.onscroll = function() { 
        if (window.pageYOffset >= 1400){
            $(".main2").css({position: "fixed", left: "0", top:"20px", background:"white"});
            $(".main2").css({"width":"290"});
            $(".main2").css({"min-height":"300"});
            $(".main2").css({"max-height":"600"});
            $(".main2").css({"overflow":"hidden"});
            $(".main2").css("zIndex", "9999");
            $(".main2").css("font-size", "9");
            $(".immagine1").css("display","none");
            $(".share").css({position: "fixed", right: "0", top: "20px", background:"white"});
            $(".share").css({"width":"120"});
            $(".share").css({"height":"100"});
        }
        else {
            $(".main2").css({position: "", right: "", top: "", background:""});
            $(".main2").css({"width":""});
            $(".main2").css({"min-height":""});
            $(".main2").css({"max-height":""});
            $(".main2").css({"overflow":""});
            $(".main2").css("zIndex", "");
            $(".main2").css("font-size", "");
            $(".immagine1").css("display","");
            $(".share").css({position: "", right: "", top: "", background:""});
            $(".share").css({"width":""});
            $(".share").css({"height":""});
        }
    }
})};
</script>

我建议为此使用插件。

我正在使用哇

最新更新