示例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
body{
margin: 0;
padding: 0;
}
.wrapper{
height: 100vh;
align-items: center;
justify-content: center;
display: flex;
flex-direction: column;
gap: 3px;
}
.wrapper:hover{
cursor: pointer;
opacity: 0.6;
transition: all 0.25s ease;
}
.wrapper.active #line2{
opacity: 0;
}
.wrapper.active #line1{
transform: rotate(45deg) translate(4px, 4.3px);
width: 21px;
}
.wrapper.active #line3{
transform: rotate(-45deg) translate(4px, -4.3px);
width: 21px;
}
.line{
background-color: black;
width: 20px;
height: 3px;
transition: all 0.25s ease;
}
</style>
<script>
onload = () => {
let ele_wrapper = document.querySelector('.wrapper');
ele_wrapper.onclick = () => {
if(ele_wrapper.classList.contains('active')){
ele_wrapper.classList.remove('active');
}else{
ele_wrapper.classList.add('active');
}
}
}
</script>
<body>
<div class="wrapper">
<div class="line" id="line1"></div>
<div class="line" id="line2"></div>
<div class="line" id="line3"></div>
</div>
</body>
</html>
A Student on the way to full stack of Web3.
Comments NOTHING