html - 为什么相同的 css 动画有时会不正确?

标签 html css mobile

我使用 CSS 为 div 的大小设置动画。我需要 div 从中心开始变大。

但是由于某些原因,在页面上有些地方可以正常工作,有些地方不行,div从左上角开始增长。

enter image description here

为什么会发生这种情况,我该如何解决?

最佳答案

试试这个!!

FlexBox 文档:https://www.w3schools.com/css/css3_flexbox.asp

.circle {
  border-radius: 100%;
  display: flex;
  transition: all 2s;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.circle.red {
  background-color: red;
}

.circle.blue {
  background-color: blue;
}

.circle.out {
  width: 200px;
  height: 200px;
}

.circle.in {
  width: 0px;
  height: 0px;
}

.circle.animate {
  animation-name: bigger;
  animation-duration: 2s;
  animation-iteration-count: infinite;
}

@keyframes bigger {
  from {
    width: 0;
    height: 0;
  }

  to {
    width: 100%;
    height: 100%;
  }
}
<div class="circle out red">
  <div class="circle in blue animate"></div>
</div>

关于html - 为什么相同的 css 动画有时会不正确?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55974335/

相关文章:

javascript - 使用 XPath 查找节点后面的文本节点

html - 使用 flexbox 包装错误

html - 使用父项修复 Bootstrap tbody 滚动

java - 图像处理和比较Android应用程序

php - 在 php 7.1 中通过 session 发送页面名称是一种好习惯吗?

html - 给 <div> 内的所有 <div> 一个 margin-bottom 10px

javascript - 仅来自类的样式属性

html - 如何使用 Bootstrap 垂直对齐不同大小的文本

android - SDK Manager 上的 2.2 API 和 4.2.2 API 有什么区别

android - 移动设备上的缩放问题虽然在桌面上工作正常