我在网站上使用hmaburger图标时遇到了一些麻烦。它在较大的视口上看起来很好,但是当您将窗口调整为较小(或在移动设备上查看)时,条形的大小变得不一致且非常难看。
我需要使用vmin大小调整,因此它完全响应但无法弄清楚问题是什么。有没有办法解决这个问题?
$(document).ready(function() {
$('.menu-icon').click(function() {
$(this).toggleClass('open');
});
});
.container {
display: block;
position: absolute;
left: 5vmin;
top: 5vmin;
}
.menu-icon {
width: 6.76vmin;
height: 5vmin;
position: relative;
bottom: 0;
right: 0;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
cursor: pointer;
}
.menu-icon span {
display: block;
position: absolute;
height: 1vmin;
width: 100%;
background: rgb(25, 27, 29);
border-radius: 1vmin;
opacity: 1;
left: 0;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transition: 0.5s ease-in-out;
-moz-transition: 0.5s ease-in-out;
-o-transition: 0.5s ease-in-out;
transition: 0.5s ease-in-out;
}
.menu-icon span:nth-child(1) {
top: 0;
}
.menu-icon span:nth-child(2),
.menu-icon span:nth-child(3) {
top: 2vmin;
}
.menu-icon span:nth-child(4) {
top: 4vmin;
}
.menu-icon.open span:nth-child(1),
.menu-icon.open span:nth-child(4) {
top: 2vmin;
width: 0%;
left: 50%;
}
.menu-icon.open span:nth-child(2) {
-webkit-transform: rotate(225deg);
-moz-transform: rotate(225deg);
-o-transform: rotate(225deg);
transform: rotate(225deg);
}
.menu-icon.open span:nth-child(3) {
-webkit-transform: rotate(-225deg);
-moz-transform: rotate(-225deg);
-o-transform: rotate(-225deg);
transform: rotate(-225deg);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<div class="container">
<div class="menu-icon">
<span></span>
<span></span>
<span></span>
<span></span>
</div>
</div>