英文:
Trying to delay the rotate transform effect on hover
问题
I am trying to delay the rotate transform effect on hover. Below is my code
.eael-offcanvas-toggle{
transition: rotate 500ms;
}
.eael-offcanvas-toggle::after{content: "///"; color: #322625; font-size: 30px;}
.eael-offcanvas-toggle:hover::after{color: #c1252b; transition: 0.1s ease-in !important; content: "|||"; transform: rotate(-0deg);}
.eael-offcanvas-toggle::before{}
But not working. Whats the problem ?
英文:
I am trying to delay the rotate transform effect on hover. Below is my code
.eael-offcanvas-toggle{
transition: rotate 500ms;
}
.eael-offcanvas-toggle::after{content: "///"; color: #322625; font-size: 30px;}
.eael-offcanvas-toggle:hover::after{color: #c1252b; transition: 0.1s ease-in !important; content: "|||"; transform: rotate(-0deg);}
.eael-offcanvas-toggle::before{}
But not working. Whats the problem ?
答案1
得分: 0
你想要复现的效果无法通过你的实现方式实现。在 CSS 中更改内容不会产生动画效果。
以下是问题和我建议你进行的更改:
.eael-offcanvas-toggle {
/* 这不是必要的 */
transition: rotate 500ms;
}
.eael-offcanvas-toggle::after {
content: "///";
color: #322625;
font-size: 30px;
/* 我们需要更改显示方式以使效果工作 */
display: inline-block;
/* 我们将过渡函数移到原始状态,以使动画双向工作 */
transition: 0.1s ease-in;
}
.eael-offcanvas-toggle:hover::after {
color: #c1252b;
/* 我们通过使用 skew 和 rotate 创建预期的效果 */
transform: rotate(-20deg) skew(0deg, 20deg);
/* 这将为过渡效果添加延迟 */
transition-delay: 300ms;
}
<div class="eael-offcanvas-toggle"></div>
英文:
The effect you want to reproduced cannot be achieved using your implementation. Changing the content doesn't animate in CSS.
These are the problems and the changes I suggest you make:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.eael-offcanvas-toggle {
/* This is not needed */
transition: rotate 500ms;
}
.eael-offcanvas-toggle::after{
content: "///";
color: #322625;
font-size: 30px;
/* We need to change the display for the effect to work */
display: inline-block;
/* We move the transition function to the original state so that the animation works both ways */
transition: 0.1s ease-in;
}
.eael-offcanvas-toggle:hover::after{
color: #c1252b;
/* We create the intended effect by using skew and rotate */
transform: rotate(-20deg) skew(0deg, 20deg);
/* This will add the delay to the transition */
transition-delay: 300ms;
}
<!-- language: lang-html -->
<div class="eael-offcanvas-toggle"></div>
<!-- end snippet -->
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论