记录:
双抽屉效果:
描述:
使用css、js实现效果。
代码块:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#d1,#d3{
width: 100px;
height: 100px;
background-color: red;
border-radius: 50%;
text-align: center;
line-height: 100px;
}
#d2{
width: 500px;
height: 100%;
background-color: blue;
position: absolute;
right: 0px;
top: 0px;
width: 0px;
transition: width 500ms;
}
#d4{
width: 300px;
height: 100%;
background-color: black;
position: absolute;
right: 0px;
top: 0px;
width: 0px;
transition: width 500ms;
}
</style>
</head>
<body>
<div id="d1">按钮</div>
<div id="d2">
<div id="d3">按钮</div>
<div id="d4"></div>
</div>
<script>
var d1=document.getElementById("d1");
var d2=document.getElementById("d2");
var d3=document.getElementById("d3");
var d4=document.getElementById("d4");
var i=0;
var j=0;
d1.onclick=function(){
if (i==0) {
d2.style.width="500px"
i=1;
}else if(i==1){
d2.style.width="0px"
d4.style.width="0px"
i=0;
}
}
d3.onclick=function(){
if (j==0) {
d4.style.width="300px"
j=1;
}else if(j==1){
d4.style.width="0px"
j=0;
}
}
</script>
</body>
</html>