zoukankan      html  css  js  c++  java
  • 小白之侧拉栏

    小白之侧拉栏

    效果:

    就是点击分享,从右边拉出一个div,再次点击回去。功能很简单。

    步骤:

    1.引入jquery。

     <script src="jquery/jquery-3.1.0.min.js"></script>

    2.创建按钮和div。

     <button class="buts">分享</button>
     <div class="divs"></div>

    3.css,主要为按钮和div的定位。

        button{position: fixed;bottom: 100px;right: 0;background: #d58512;width: 30px;padding: 5px;font-size: 20px;}
        div{position: fixed;bottom:0;right:-250px;background: #fff;width: 238px;height:150px;padding: 5px;font-size: 20px;border: 1px solid #ccc}

    4.js

     $(function () {
                $(".buts").click(function () {
                    if($(this).css("right")=="0px"){
                    $(this).animate({right:'250px'},'slow');
                    $(".divs").animate({right:'0px'},'slow');
                }else {
                    $(this).animate({right:'0px'},'slow');
                    $(".divs").animate({right:'-250px'},'slow');
                }})
            })

    html代码展示:

    <!DOCTYPE html>
    <html>
    <head lang="en">
        <meta charset="UTF-8">
        <title></title>
        <script src="jquery/jquery-3.1.0.min.js"></script>
        <style>
            button{position: fixed;bottom: 100px;right: 0;background: #d58512;width: 30px;padding: 5px;font-size: 20px;}
            div{position: fixed;bottom:0;right:-250px;background: #fff;width: 238px;height:150px;padding: 5px;font-size: 20px;border: 1px solid #ccc}
        </style>
    </head>
    <body>
        <button class="buts">分享</button>
        <div class="divs"></div>
        <script>
            $(function () {
                $(".buts").click(function () {
                    if($(this).css("right")=="0px"){
                        $(this).animate({right:'250px'},'slow');
                        $(".divs").animate({right:'0px'},'slow');
                    }else {
                        $(this).animate({right:'0px'},'slow');
                        $(".divs").animate({right:'-250px'},'slow');
                    }})
            })
        </script>
    </body>
    </html>
    View Code
  • 相关阅读:
    Java学习笔记-函数
    Java学习笔记-数组
    Git 常用命令速查表
    $.fn与$.fx什么意思; $.extend与$.fn.extend用法区别; $(function(){})和(function(){})(jQuery)
    offsetWidth的bug
    jQuery对象和DOM对象转换,解决jQuery对象不能使用js方法的问题
    1
    $().ready()与window.onload的不同
    offsetHeight在不同的浏览器下取值不同
    getElementsByName兼容ie 但并不是兼容ie下的所有标签
  • 原文地址:https://www.cnblogs.com/s313139232/p/7508502.html
Copyright © 2011-2022 走看看