点击按钮向左侧滑动效果
2017-12-27 15:19
127 查看
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>向左侧滑动效果</title>
<-- 需引入手册 -->
<script src="jquery-1.8.3.min.js"></script>
<style>
*{
margin: 0;
padding: 0;
}
img{
border: 0;
}
li{
list-style: none;
}
a{
text-decoration: none;
}
.btn{
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{
width: 100%;
height: 100%;
display: none;
}
.btn_show_bg{
width: 100%;
height: 100%;
background: #000;
position: fixed;
top: 0;
left: 0;
opacity: 0.5;
}
.btn_show_main{
width: 300px;
height: 100%;
background: #fff;
position: fixed;
top: 0;
right: -300px;
}
.btn_show_main_close{
font-size: 14px;
width: 100px;
height: 20px;
line-height: 20px;
text-align: center;
cursor: pointer;
}
.div_right0{
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{
100% {background:red; right:0px; top:0px;}
}
.div_right{
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{
100% {background:blue; right:-300px; top:0px;}
}
.btn_show_main ul li{
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(){
$(".btn").click(function(){
$(".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(){
$(".btn_show_main").addClass('div_right');
$(".btn_show_main").removeClass('div_right0');
$(".btn_show_bg").hide(2000);
});
};
</script>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>向左侧滑动效果</title>
<-- 需引入手册 -->
<script src="jquery-1.8.3.min.js"></script>
<style>
*{
margin: 0;
padding: 0;
}
img{
border: 0;
}
li{
list-style: none;
}
a{
text-decoration: none;
}
.btn{
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{
width: 100%;
height: 100%;
display: none;
}
.btn_show_bg{
width: 100%;
height: 100%;
background: #000;
position: fixed;
top: 0;
left: 0;
opacity: 0.5;
}
.btn_show_main{
width: 300px;
height: 100%;
background: #fff;
position: fixed;
top: 0;
right: -300px;
}
.btn_show_main_close{
font-size: 14px;
width: 100px;
height: 20px;
line-height: 20px;
text-align: center;
cursor: pointer;
}
.div_right0{
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{
100% {background:red; right:0px; top:0px;}
}
.div_right{
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{
100% {background:blue; right:-300px; top:0px;}
}
.btn_show_main ul li{
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(){
$(".btn").click(function(){
$(".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(){
$(".btn_show_main").addClass('div_right');
$(".btn_show_main").removeClass('div_right0');
$(".btn_show_bg").hide(2000);
});
};
</script>
</html>
相关文章推荐
- iOS 在tableView上添加button导致按钮没有点击效果和不能滑动的 zhuang
- iOS 在tableView上添加button导致按钮没有点击效果和不能滑动的问题
- iOS开发:多个按钮点击滑动效果
- viewpager的setCurrentItem 底部导航栏点击按钮实现直接跳转,去掉滑动效果
- 代码实现按钮点击高亮效果
- android仿IOS按钮点击效果,一张图片实现
- 使用js实现按钮的滑动效果
- android按钮点击动画特效,有关注按钮点击效果,有收藏按钮,点赞按钮,评论按钮等各种效果
- Android实现渐显按钮的左右滑动效果
- jquery 实现 点击按钮后倒计时效果,多用于实现发送手机验证码、邮箱验证码
- Android_UI_点击按钮切换背景效果实现
- android 关于按钮点击效果的方法
- 导航条点击按钮切换效果
- android按钮被点击文字颜色变化效果
- Android开发之按钮点击效果浅析
- 不使用JS,使用CSS3 target 以及 动画效果实现,点击一下弹出,并且保持弹出状态,然后再点击一下弹回的导航栏(或者可以叫做按钮)
- jquery 实现 点击按钮后倒计时效果,多用于实现发送手机验证码、邮箱验证码
- JS窗口最大化(模拟最大化和点击最大化按钮效果)
- 【代码笔记】点击一个按钮会出现多个按钮的动画效果
- js通过更改按钮的显示样式实现按钮的滑动效果