📝 代码查看
2
查看次数
2025-11-07
创建时间
2025-11-07
最后更新
<div class="wrapper">
<button class="menu">
Menu
<span></span>
<span></span>
<span></span>
</button>
<button class="menu-2">
Menu
<span></span>
<span></span>
<span></span>
</button>
</div>
.menu {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
font-size: 0;
width: 50px;
height: 45px;
border: 0;
background: transparent;
border: 0;
cursor: pointer;
}
.menu span {
display: block;
width: 80%;
height: 3px;
background: #000;
margin-bottom: 5px;
margin-left: auto;
margin-right: auto;
}
.menu span:last-child {
margin-bottom: 0;
}
.menu-2 {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
display: inline-block;
width: 28px;
height: 18px;
font-size: 0;
padding: 0;
border: 0;
background: transparent;
cursor: pointer;
margin-left: 100px;
}
.menu-2 span {
display: block;
width: 100%;
height: 3px;
background: #000;
margin-bottom: 5px;
}
.menu,
.menu-2 {
position: relative;
}
.menu:after,
.menu-2:after {
content: "";
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: #EEBACD;
z-index: -1;
opacity: 0;
transition: 0.2s ease-out;
}
.menu:hover:after,
.menu-2:hover:after {
opacity: 1;
}
.wrapper {
margin-top: 100px;
text-align: center;
}
document.querySelector('.menu').addEventListener('click', function () {
alert('clicked!');
});