【问题标题】:CSS ease in and out on hoverCSS 在悬停时缓入和缓出
【发布时间】:2017-05-07 03:32:09
【问题描述】:

我有一个简单的 div,它是圆形的,border-radius 为 50%。在hover 上,边界半径变为零。我使用了以下完美运行的 css 代码。

.design-box {
  width: 100%;
  height: 250px;
  margin: 100px auto;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  position: relative;
}

.design-box:hover {
  border-radius: 0;
  -webkit-transition: all 1s ease;
  transition: all 1s ease;
}
<div class="design-box"></div>

我想要发生的是,当 div 不再悬停时,我希望转换到 ease out 并慢慢转换回原来的 50% border-radius。我不能让它工作,我在这里错过了一个简单的步骤吗?

谢谢

【问题讨论】:

  • 将过渡添加到 .design-box 类,而不是悬停

标签: css hover css-transitions


【解决方案1】:

仅将transition置于正常状态:

.design-box {
  transition: all 1s ease;
}

看看下面的sn-p:

.design-box {
  width: 100%;
  height: 250px;
  margin: 100px auto;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  position: relative;
  transition: all 1s ease;
}

.design-box:hover {
  border-radius: 0;
}
<div class="design-box"></div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-19
    • 1970-01-01
    • 2017-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-23
    • 1970-01-01
    相关资源
    最近更新 更多