我正在CSS中实现类似iOS的弯曲人字形
我现在所做的一切都很好,除了过渡上的像素化
document.addEventListener('click', (e) => {
document.querySelector('body').classList.toggle('bends-up')
});
body {
display: flex;
background: salmon;
justify-content: center;
align-items: center;
flex-direction: column;
height: 100vh;
color: white;
font-family: Helvetica;
user-select: none;
}
body .comment-up {
display: none;
color: yellow;
}
body span {
color: cyan;
}
body.bends-up span {
display: none;
}
body.bends-up .comment-up {
display: inline;
}
body.bends-up .chevron:hover:before {
transform: translateX(0.5px) rotate(-20deg);
}
body.bends-up .chevron:hover:after {
transform: translateX(-0.5px) rotate(20deg);
}
.chevron {
width: 40px;
height: 4px;
margin: 60px auto;
position: relative;
transform: scale(10);
}
.chevron:before, .chevron:after {
opacity: 0.5;
transition: opacity 0.2s;
position: absolute;
content: "";
width: 22px;
height: 4px;
border-radius: 2px;
background: white;
transition: transform 0.4s, border-radius 0.2s;
transition-delay: 0, 0.4s;
}
.chevron:before {
left: 0;
}
.chevron:after {
right: 0;
}
.chevron:hover:after, .chevron:hover:before, .chevron:active:after, .chevron:active:before {
opacity: 0.9;
}
.chevron:hover:before {
transform: translateX(0.5px) rotate(20deg);
}
.chevron:hover:after {
transform: translateX(-0.5px) rotate(-20deg);
}
<h1>
Hover to see bend
<span>down</span>
<span class="comment-up">up</span>
animation
</h1>
<div class="chevron"></div>
<h2>
Click to toggle up/down bend
</h2>