新增第237个小实例:菜单按钮的三种切换动画
This commit is contained in:
parent
89d0897522
commit
666221b517
|
@ -244,6 +244,7 @@
|
|||
234. HTML5+CSS3+JS小实例:圣诞按钮
|
||||
235. HTML5+CSS3+JS小实例:图片切换特效之模糊变清晰
|
||||
236. HTML5+CSS3小实例:荧光图标悬停效果
|
||||
237. HTML5+CSS3小实例:菜单按钮的三种切换动画
|
||||
|
||||
#### 赞赏作者
|
||||
![image](https://gitee.com/wyanhui02/html_css_demo/raw/master/images/%E8%B5%9E%E8%B5%8F%E4%BD%9C%E8%80%85/%E8%B5%9E%E8%B5%8F%E7%A0%81.jpg)
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
*{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
body{
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background-color: #181818;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
.container{
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 56px;
|
||||
}
|
||||
/* 菜单按钮的统一样式 */
|
||||
.menu-btn{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
z-index: 99;
|
||||
height: auto;
|
||||
}
|
||||
.menu-btn input{
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
display: block;
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
z-index: 9;
|
||||
opacity: 0;
|
||||
}
|
||||
/* 菜单一 */
|
||||
.menu-btn.one span{
|
||||
width: 35px;
|
||||
height: 3px;
|
||||
background-color: #4e4e4e;
|
||||
position: relative;
|
||||
margin: 4px 0;
|
||||
border-radius: 2px;
|
||||
transition: all 0.2s linear;
|
||||
}
|
||||
.menu-btn.one input:checked ~ span:nth-of-type(1){
|
||||
opacity: 1;
|
||||
transform: rotate(-45deg) translate(-6px,5px);
|
||||
background-color: #eb30ba;
|
||||
box-shadow: 0 0 2em 0.2em #eb30ba;
|
||||
}
|
||||
.menu-btn.one input:checked ~ span:nth-of-type(2){
|
||||
opacity: 0;
|
||||
}
|
||||
.menu-btn.one input:checked ~ span:nth-of-type(3){
|
||||
opacity: 1;
|
||||
transform: rotate(45deg) translate(-5px,-5px);
|
||||
background-color: #eb30ba;
|
||||
box-shadow: 0 0 2em 0.2em #eb30ba;
|
||||
margin-top: -3px;
|
||||
width: 35px;
|
||||
}
|
||||
/* 菜单二 */
|
||||
.menu-btn.two span{
|
||||
width: 35px;
|
||||
height: 3px;
|
||||
background-color: #4e4e4e;
|
||||
position: relative;
|
||||
margin: 4px 0;
|
||||
border-radius: 2px;
|
||||
transition: all 0.2s linear;
|
||||
}
|
||||
.menu-btn.two span:nth-of-type(2){
|
||||
width: 25px;
|
||||
margin-bottom: auto;
|
||||
}
|
||||
.menu-btn.two span:nth-of-type(3){
|
||||
width: 25px;
|
||||
opacity: 0;
|
||||
margin: 0;
|
||||
}
|
||||
.menu-btn.two input:checked ~ span:nth-of-type(1){
|
||||
opacity: 0;
|
||||
transform: scale(0);
|
||||
}
|
||||
.menu-btn.two input:checked ~ span:nth-of-type(2){
|
||||
transform: rotate(45deg);
|
||||
width: 35px;
|
||||
background-color: #29cda7;
|
||||
box-shadow: 0 0 2em 0.2em #29cda7;
|
||||
}
|
||||
.menu-btn.two input:checked ~ span:nth-of-type(3){
|
||||
transform: rotate(135deg);
|
||||
opacity: 1;
|
||||
width: 35px;
|
||||
background-color: #29cda7;
|
||||
box-shadow: 0 0 2em 0.2em #29cda7;
|
||||
margin-top: -3px;
|
||||
}
|
||||
.menu-btn.two input:checked ~ span:nth-of-type(4){
|
||||
opacity: 0;
|
||||
transform: scale(0);
|
||||
}
|
||||
/* 菜单三 */
|
||||
.menu-btn.three span{
|
||||
height: 3px;
|
||||
width: 35px;
|
||||
position: relative;
|
||||
background-color: #4e4e4e;
|
||||
margin: 4px 0;
|
||||
border-radius: 2px;
|
||||
transition: all 0.2s linear;
|
||||
}
|
||||
.menu-btn.three span:nth-of-type(1){
|
||||
width: 20px;
|
||||
margin-right: auto;
|
||||
}
|
||||
.menu-btn.three span:nth-of-type(2){
|
||||
width: 40px;
|
||||
}
|
||||
.menu-btn.three span:nth-of-type(3){
|
||||
width: 20px;
|
||||
margin-left: auto;
|
||||
}
|
||||
.menu-btn.three input:checked ~ span:nth-of-type(1){
|
||||
transform: rotate(45deg) translate(4px,1px);
|
||||
background-color: #f4f726;
|
||||
box-shadow: 0 0 2em 0.2em #f4f726;
|
||||
}
|
||||
.menu-btn.three input:checked ~ span:nth-of-type(2){
|
||||
transform: rotate(-45deg);
|
||||
background-color: #f4f726;
|
||||
box-shadow: 0 0 2em 0.2em #f4f726;
|
||||
}
|
||||
.menu-btn.three input:checked ~ span:nth-of-type(3){
|
||||
transform: rotate(45deg) translate(-4px,0px);
|
||||
background-color: #f4f726;
|
||||
box-shadow: 0 0 2em 0.2em #f4f726;
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>菜单按钮的三种切换动画</title>
|
||||
<link rel="stylesheet" href="237.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="menu-btn one">
|
||||
<input type="checkbox">
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
</div>
|
||||
<div class="menu-btn two">
|
||||
<input type="checkbox">
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
</div>
|
||||
<div class="menu-btn three">
|
||||
<input type="checkbox">
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue