dd

发一个简短的置顶和显示二维码的一段代码,需要的拿去

jerry thinkphp 2015年11月19日 收藏
发一个简短的置顶和显示二维码的一段代码,需要的拿去
CSS样式的实现
.left-float{position:fixed; right:40px; bottom:60px; width:40px; height:140px; z-index:10000000;}
.left-float .qr-code,.left-float .gototop{width:40px; height:40px; padding:10px; margin-bottom:5px; background:#FFFFFF; text-align:center; line-height:40px; font-size:40px; cursor:pointer; color:#428BCA; font-family:"微软雅黑"; font-weight:bold;}
.left-float .gototop{display:none;}
.left-float .qr-code-box{width:250px; height:250px; position:absolute; left:-250px; top:-100px; overflow:hidden; display:none;}
.left-float .qr-code-box img{width:250px; height:250px;}
html代码的实现
<!--返回顶部和二维码显示-->
<div class="left-float midfix">
    <div class="qr-code"> ※ </div>
    <div class="qr-code-box">
        <img src="__PUBLIC__/Static/img/weixin.jpg" alt="{$site_name}" />
    </div>
    <div class="gototop" id="goToTop"> ∴ </div>
</div>
javascript代码的实现
<script type="text/javascript">
$(window).scroll(function(){
    var scrTop = $(window).scrollTop();
    var windowTop = $(window).height();
    if ((windowTop-300)<scrTop){
        $(".gototop").fadeIn("slow");
    }else{
        $(".gototop").fadeOut("slow");
    }
});

$('.qr-code').mouseenter(function(){
    $('.qr-code-box').fadeIn("slow");
}).mouseleave(function(){
    $('.qr-code-box').fadeOut("slow");
});
$('#goToTop').click(function(){
    $('html,body').animate({scrollTop: '0px'}, 300);
});
</script>
dd