(转)点击按钮向左侧滑动效果(Drawer 抽屉)

42 篇文章 0 订阅

平时都是使用ui组件库里的轮子实现动效,古老项目需要原生实现一下,记录一下。 

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<title>向左侧滑动效果</title>

<script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>

<style>
*{undefined
margin: 0;
padding: 0;
}
img{undefined
border: 0;
}
li{undefined
list-style: none;
}
a{undefined
text-decoration: none;
}


.btn{undefined
width: 100px;
height: 30px;
line-height: 30px;
border: 1px solid;
margin: 0 auto;
margin-top: 100px;
text-align: center;
cursor: pointer;
border-radius: 6px;
}
.btn_show{undefined
width: 100%;
height: 100%;
display: none;
}


.btn_show_bg{undefined
width: 100%;
height: 100%;
background: #000;
position: fixed;
top: 0;
left: 0;
opacity: 0.5;
}
.btn_show_main{undefined
width: 300px;
height: 100%;
background: #fff;
position: fixed;
top: 0;
right: -300px;
}
.btn_show_main_close{undefined
font-size: 14px;
width: 100px;
height: 20px;
line-height: 20px;
text-align: center;
cursor: pointer;
}

.div_right0{undefined
animation:myfirstss 2s;
-moz-animation:myfirstss 2s; /* Firefox */
-webkit-animation:myfirstss 2s; /* Safari and Chrome */
-o-animation:myfirstss 2s; /* Opera */
animation-fill-mode: forwards;
}
@keyframes myfirstss{undefined
100% {background:red; right:0px; top:0px;}
}
.div_right{undefined
animation:myfirsts 2s;
-moz-animation:myfirsts 2s; /* Firefox */
-webkit-animation:myfirsts 2s; /* Safari and Chrome */
-o-animation:myfirsts 2s; /* Opera */
animation-fill-mode: forwards;
right: 0px;
}
@keyframes myfirsts{undefined
100% {background:blue; right:-300px; top:0px;}
}
.btn_show_main ul li{undefined
width: 100%;
height: 20px;
line-height: 20px;
text-align: center;
font-size: 14px;
margin-bottom: 10px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="btn">按钮</div>

<div class="btn_show">
<div class="btn_show_bg"></div>
<div class="btn_show_main">
<div class="btn_show_main_close">我是关闭</div>
<ul>
<li>我是1</li>
<li>我是2</li>
<li>我是3</li>
<li>我是4</li>
<li>我是5</li>
<li>我是6</li>
<li>我是7</li>
<li>我是8</li>
<li>我是9</li>
<li>我是10</li>
</ul>
</div>
</div>
</body>
<script>
window.onload = function(){undefined
    $(".btn").click(function(){undefined
        $(".btn_show").show();
        $(".btn_show_bg").show();
        $(".btn_show_main").addClass('div_right0');
        $(".btn_show_main").removeClass('div_right')
    });

    $(".btn_show_main_close").click(function(){undefined
        $(".btn_show_main").addClass('div_right');
        $(".btn_show_main").removeClass('div_right0');
        $(".btn_show_bg").hide(2000);
    });
};

</script>
</html>

链接:点击按钮向左侧滑动效果_☞小阿平☜的博客-CSDN博客_css3 向左滑动

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值