CSS ONLY Animate Draw Circle with border-radius and透明背景 [英] CSS ONLY Animate Draw Circle with border-radius and transparent background
问题描述
我正在尝试绘制一个带有边界半径的圆,并为其设置动画.我可以做到这一点,但我不能做的是覆盖元素并将圆圈背景设置为透明,而不隐藏蒙版.我无法让它在元素上透明,因为需要应用蒙版来隐藏圆圈的左半部分,因为它旋转以模仿绘制效果.
HTML
<div class="wrapper"><div class="pie spinner"></div><div class="馅饼填料"></div><div class="mask"></div>
CSS
.background{背景:绿色;z-索引:1000;}.包装{宽度:250px;高度:250px;位置:相对;边距:40px 自动;背景:RGBA(0,0,255,1);}.wrapper, .wrapper * {-moz-box-sizing: 边框框;-webkit-box-sizing: 边框框;box-sizing: 边框框;}.wrapper .pie {宽度:50%;高度:100%;变换原点:100% 50%;位置:绝对;背景:透明;边框:5px 实心 rgba(0,0,0,0.9);}.wrapper .spinner {边界半径:100% 0 0 100%/50% 0 0 50%;z-索引:0;边界右:无;-webkit-animation:旋转 5s 线性无限;}.wrapper: 悬停 .spinner,.wrapper: 悬停 .filler,.wrapper:hover .mask {动画播放状态:运行;}.wrapper .filler {边界半径:0 100% 100% 0/0 50% 50% 0;左:50%;不透明度:0;-webkit-animation: opa 5s steps(1, end) 无限反转;左边界:无;}.wrapper .mask {宽度:50%;高度:100%;位置:绝对;背景:继承;不透明度:1;-webkit-animation: opa 5s steps(1, end) 无限;}@-webkit-keyframes 旋转 {0% {变换:旋转(0度);边框颜色:红色;}100% {变换:旋转(360度);z-index:0;}}@-webkit-keyframes opa {0% {不透明度:1;}50%, 100% {不透明度:0;}}
http://jsfiddle.net/BuzzSmarter/gmvban4p/
在我的示例中,我需要将蓝色背景更改为透明,并且在开始旋转之前不取消隐藏边框半径.
请原谅颜色,这些不是我将要处理的,但提供了一个更清晰的方法来解决这个问题.
这是我的临时产品,我必须去除绘图才能实现透明度.http://jsfiddle.net/BuzzSmarter/gmvban4p/
这是我的解决方案.
我在身体上设置了背景以显示它是透明的
body {背景:重复线性渐变(45 度,白色 0 像素,浅蓝色 100 像素);高度:500px;背景尺寸:500px 500px;背景重复:不重复;}html {高度:100%;}#容器 {位置:绝对;宽度:400px;高度:400px;边框:纯红色1px;动画:颜色 4s 无限;}#halfclip {宽度:50%;高度:100%;右:0px;位置:绝对;溢出:隐藏;变换原点:左中心;动画:cliprotate 16s steps(2) 无限;-webkit-animation:cliprotate 16s steps(2) 无限;}.半圆{box-sizing: 边框框;高度:100%;右:0px;位置:绝对;边框:实心25px透明;边框顶部颜色:蓝色;边框左颜色:蓝色;边界半径:50%;}#剪辑{宽度:200%;动画:旋转8s线性无限;-webkit-animation: 旋转 8s 线性无限;}#固定的 {宽度:100%;变换:旋转(135度);动画:showfixed 16s step(2)无限;-webkit-animation:显示固定的 16 秒线性无限;}@-webkit-keyframes 剪辑{0% {变换:旋转(0度);}100% {变换:旋转(360度);}}@keyframes 剪辑{0% {变换:旋转(0度);}100% {变换:旋转(360度);}}@-webkit-keyframes 旋转 {0% {变换:旋转(-45度);}100% {变换:旋转(135度);}}@关键帧旋转{0% {变换:旋转(-45度);}100% {变换:旋转(135度);}}@-webkit-keyframes showfixed {0% {不透明度:0;}49.9% {不透明度:0;}50% {不透明度:1;}100% {不透明度:1;}}
<div id="halfclip"><div class="halfcircle" id="clipped">
<div class="halfcircle" id="fixed">