【发布时间】:2019-07-31 23:16:41
【问题描述】:
为什么当背景没有应用于动画时,边框半径不起作用。
边框半径仅在应用背景为 0%-50%-100% 时有效。没有背景颜色,边框半径不起作用。
我希望边框半径从正方形变为圆形,然后再变回正方形。
.square {
/* Set up the normal state */
display: block;
width:350px;
height:350px;
margin: 200px auto;
background:#41A9F0;
/* apply the animation */
animation: box 5s linear infinite;
}
@keyframes box {
0% {
transform: rotate(0) scale(0.2);
/* background: #41A9F0; */
border-radius: 0%;
}
50% {
transform: rotate(180deg) scale(2);
/* background: #5ABE8A; */
border-radius: 50%;
}
100% {
transform: rotate(360deg) scale(0.2);
/* background: #41A9F0; */
border-radius: 0%;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Shape Animation Challenge</title>
</head>
<body>
<!-- HINTS
1) Open shape-animation-ANSWER.html in your browser and try to create the final product.
2) Create a keyframe named box.
3) There are three points to this animation, starts off as a square, then a circle (background color for the circle is #5ABE8A), then back to a square.
Hint: You will need the properties border-radius and transform -->
<div class="square"></div>
</body>
</html>
【问题讨论】:
-
我不太关注。您可以删除背景,它仍然有效?请参阅jsfiddle.net/Larfk32m 仅供参考:我在元素上设置了边框,因此您仍然可以看到元素/动画。
-
我的问题是为什么没有背景它不能工作?背景是否设置了使边框半径起作用的默认边框?
标签: html css css-animations