css - 当我通过过渡/动画增加大小时,元素子元素 "shakes"

标签 css

我这里有一个圆圈,当我将鼠标悬停在它上面时,它会随着大小而增加。当我这样做时,中间的“+”会“震动”。

HTML

    <div class='test-ani'>
       <span>+</span>
    </div>

CSS

.test-ani {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-color: cornflowerblue;
    user-select: none;
    cursor: pointer;

    &:hover {
        transition: .5s;
        width: 120px;
        height: 120px;
    }

    span {
        color: #ffdb58;
        font-size: 50px;
        padding: 0;
        margin: 0;
    }
}

视觉动图

enter image description here

最佳答案

动画转换规则:

section {
  position: relative;
  width: 100%;
  height: 100%;
}
.test-ani {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background-color: cornflowerblue;
  user-select: none;
  cursor: pointer;
}
.test-ani:hover {
  transition: transform .5s;
  transform: scale(1.2);
}
.test-ani span {
  color: #ffdb58;
  font-size: 50px;
  padding: 0;
  margin: 0;
}
<section>
  <div class='test-ani'>
     <span>+</span>
  </div>
</section>

关于css - 当我通过过渡/动画增加大小时,元素子元素 "shakes",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52574089/

相关文章:

html - btn-group 与子菜单 twitterbootstrap

jquery - css3 动画/过渡

javascript - 如何使下拉框将纯CSS中的所有内容置于上方和前面?

javascript - jQuery 对话框中的 Z-index。自动建议列表未正确显示

jquery - 使用 jquery 从数组更改图像 src

javascript - SVG 溢出在 chrome 中可见但在元素后面

html - 如何避免悬停时盒子移动?

html - 仅在三个侧面有多个插入框阴影和 alpha 透明度的阴影

javascript:将温度映射到特定的 HSL 色调值

jquery - 如何使用 Bootstrap 在一行中制作我的 Logo 、搜索栏和图标?