使用css3 的 animation 属性实现的点击滑出侧栏

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<meta name="author" content="TKB-nice" />
<style>
*{
margin: 0;
padding: 0;
}
body{
height: 100%;
position: relative;
top: 0;
left: 0;
}
html{
height: 100%;
background-color: #eee;
}
li{
list-style: none;
}
.page{
height: 100%;
width: 100%;
overflow: hidden;
}
.list li:last-child{
margin-top: 5px;
background-color: skyblue;
} .text{
height: 50%;
}
.close{
height: 50%;
}
.side-bar{
display: none;
width: 100%;
height: 100%;
background-color: orange;
position: absolute;
top: 0;
z-index: 99;
} @keyframes mymove
{
from {left:100%;}
to {left:50%;}
}
@-webkit-keyframes mymove
{
from {left:100%;}
to {left:0;}
}
@keyframes myleave
{
from {left:50%;}
to {left:100%;}
}
@-webkit-keyframes myleave
{
from {left:0;}
to {left:100%;}
}
</style>
</head>
<body>
<div class="page">
<div class="mian">
<ul class="list">
<li class="item1" id="item1">侧栏1</li>
<li class="item2" id="item2">侧栏2</li>
</ul>
</div>
<div class="side-bar" id="side-bar1">
<p class="text">我是侧栏111111111</p>
<p class="close" id="close1">点击关闭</p>
</div>
<div class="side-bar" id="side-bar2">
<p class="text">我是侧栏2222222</p>
<p class="close" id="close2">点击关闭</p>
</div>
</div> <script>
document.getElementById('item1').onclick=function(){
document.getElementById('side-bar1').style.animation = 'mymove 0.5s ease forwards';
document.getElementById('side-bar1').style.display = 'block';
}
document.getElementById('item2').onclick=function(){
document.getElementById('side-bar2').style.animation = 'mymove 0.5s ease forwards';
document.getElementById('side-bar2').style.display = 'block';
}
document.getElementById('close1').onclick=function(){
document.getElementById('side-bar1').style.animation = 'myleave 0.5s ease forwards ';
setTimeout(function(){
document.getElementById('side-bar1').style.display = 'none';
},500); }
document.getElementById('close2').onclick=function(){
document.getElementById('side-bar2').style.animation = 'myleave 0.5s ease forwards ';
setTimeout(function(){
document.getElementById('side-bar2').style.display = 'none';
},500); }
</script>
</body>
</html>

最新文章

  1. LeetCode 299 Bulls and Cows
  2. maven环境配置+eclipse环境配置
  3. Excel顺序生成序号,不能有数字4出现
  4. get_object_vars($var) vs array($var)
  5. 【TypeScript】如何在TypeScript中使用async/await,让你的代码更像C#。
  6. Java中的定时器Timer
  7. (转)分布式缓存GemFire架构介绍
  8. 关于websocket中的心跳..
  9. newifi升级固件及开启SSH
  10. canvas1
  11. delphi中获得进程列表或想要的进程(枚举进程、遍历进程)
  12. css2--垂直对齐
  13. Python Socket请求网站获取数据
  14. (转)vim中多行注释
  15. LR(0)文法项目集规范族、DFA和分析表的构建实例
  16. python flask 项目结构
  17. ubuntu 开机自启(2B的经历)
  18. MVC 源码调试
  19. day7学python 初识简单模板
  20. Django中遇到的mysql问题

热门文章

  1. SpringBoot Actuator监控【转】
  2. poj2449第K短路问题(A*算法)
  3. Directx11教程(57) 环境映射
  4. 初探postman
  5. iis7服务器隐藏index.php
  6. 前端基础☞html
  7. 设置WPF窗口相对于非WPF窗口的位置
  8. jsp页面关建字查询出记录后,点下一页关键字会清空,怎么保持关键字不变而进行下一页操作?
  9. 交互式计算和开发环境:IPython
  10. Python深入:Distutils发布Python模块