html - 填充泪滴CSS3

标签 html css animation

我试图填充泪滴以将其用作预加载器

这是代码

#drop {
  margin: 100px auto;	
  width: 300px;
  height: 300px;
  border-bottom-right-radius: 50%;
  border-bottom-left-radius: 50%;
  border-top-left-radius: 50%;
  -webkit-transform:rotate(-45deg);
  z-index: 99;
  position: relative;
  background: #fff;
  border: 1px solid #e74c3c;
  overflow: hidden;
}
#drop::before {
  content: '';
  position: absolute;
  background: #e74c3c;
  width: 100%; 
  bottom: 0;
  animation: wipe 5s cubic-bezier(.2,.6,.8,.4) forwards infinite;
}
@keyframes wipe {
  0% {
    height: 0;
  }
  100% {
    height: 100%;
  }
} 
<div id="drop"></div>

我尝试使用变换和边距但失败了

提前致谢

最佳答案

我使用了 border-radius 的简写,我所做的其他更改是针对 pseudo 元素

  • 元素的大小加倍。
  • 元素放在中心
  • 使用 transform: translate(-100%, 10%) rotate(45deg);
  • 将其定位在元素的底部
  • 在关键帧中,我将 pseudo 元素移动到顶部

  #drop {
  margin: 100px auto;
  width: 300px;
  height: 300px;
  border-radius: 50% 0 50% 50%;
  -webkit-transform: rotate(-45deg);
  z-index: 99;
  position: relative;
  background: #fff;
  border: 1px solid #e74c3c;
  overflow: hidden;
}

#drop::before {
  content: '';
  position: absolute;
  background: #e74c3c;
  height: 200%;
  width: 200%;
  transform: translate(-100%, 10%) rotate(45deg);
  top: 50%;
  left: 50%;
  transform-origin: center;
  animation: wipe 5s cubic-bezier(.2, .6, .8, .4) forwards infinite;
}

@keyframes wipe {
  0% {
    transform: translate(-100%, 10%) rotate(45deg);
  }
  100% {
    transform: translate(-50%, -50%) rotate(45deg);
  }
<div id="drop"></div>

关于html - 填充泪滴CSS3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42446159/

相关文章:

html - 更改特定的输入颜色文本

php - IE11 CSS动画问题

javascript - 反转 CSS 动画

r - 如何制作高平滑、高分辨率的粒子运动动画

javascript - 如果验证成功隐藏提交按钮并显示加载图像

php - 使用 from info 创建一个自动 div

php - 循环是建表的最佳方式吗?

html - 表格数据何时不是表格数据?

html - Css 如果元素没有特定的类

javascript - 根据文本换行和窗口宽度更改 CSS 类(Jquery 或 JavaScript)