尝试延迟悬停时的旋转变换效果

huangapple go评论98阅读模式
英文:

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: &quot;///&quot;;
  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 -->

&lt;div class=&quot;eael-offcanvas-toggle&quot;&gt;&lt;/div&gt;

<!-- end snippet -->

huangapple
  • 本文由 发表于 2023年5月21日 18:39:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76299454.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定