右侧常用浮动导航

本文介绍了一种使用JavaScript和jQuery实现的网页元素固定展示方法,并详细解释了如何让元素随滚动条出现或隐藏,同时提供了回到顶部的功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<div class="right_nav">
      <p class="right1"><a href="#" target="_self">收藏本页</a></p>
      <p class="right1 right2"><a href="#" target="_self">分享活动</a></p>
      <p class="right1 right2">在线咨询</p>
      <p class="right1 right3"></p>
</div>

 

.right_nav{ width:92px; background:#FFF;  position: fixed; right:2px;bottom:100px;z-index:9999;}
.right_nav ul{ border:1px #DFDFDF solid; background:#FFF; border-bottom:0;}
.right_nav li{ width:100px; margin-left:8px; height:36px; line-height:36px; text-align:center; border-bottom:1px #E9E9E9 solid;}
.right_nav li img{ vertical-align:middle; cursor:pointer;}
.right_nav li a{ text-decoration:none; color:#666666;}
.right_nav li .aa{color:#666666; font-weight:bold;}
.right_nav li.youj{ background:url(images/ico6.jpg) no-repeat 8px center; text-indent:24px;}
.right_nav .p2{ cursor:pointer;}
.right_nav .pwx{color:#666666; text-align:center; line-height:22px; margin:4px 0;}

 

 

<script>
$(function(){
        //$(".dh_box_bg ul li:odd").css({ background: "#FFF6E4",border:"1px #FFF6E4 solid" });

 
   $(window).scroll(function(){
        if($(this).scrollTop()>300){
           $(".left_nav").css("display","block");
        }else{
           $(".left_nav").css("display","none");
        };    
    });
    
     //回到页面顶部位置
    $(".p2").click(function(){
        $('body,html').animate({scrollTop:0},600);
       return false;
    });

})
</script>


<script>
$(function(){
jQuery(document).ready(function() {
    jQuery(".right_nav ul li a").click(function() {
        jQuery("html, body").animate({
            scrollTop: jQuery(jQuery(this).attr("href")).offset().top+ "px"
        }, {
            duration: 500,
            easing: "swing"
        });
        return false;
    });
});
     //回到页面顶部位置
    $(".p2").click(function(){
        $('body,html').animate({scrollTop:0},600);
       return false;
    })
       $(window).scroll(function(){
        if($(this).scrollTop()>200){
           $(".right_nav").css("display","block");
        }else{
           $(".right_nav").css("display","none");
        };    
    });
})
</script>

 

转载于:https://www.cnblogs.com/su1637/p/8204332.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值