我创建了以下代码,它有点像加载动画。
body {
background-color: #fafafa;
}
.container {
width: 700px;
height: 400px;
background-color: white;
margin: 0 auto;
box-shadow: 17px 17px 45px #d1d1d1;
text-align: center;
vertical-align: middle;
}
.title {
font-family: 'Open Sans', sans-serif;
font-weight: 600;
font-size: 180%;
text-align: center;
position: relative;
padding-top: 20px;
color: orangered;
}
.circle {
height: 50px;
width: 50px;
border-radius: 50%;
background-color: #d3e6e6;
margin: 10px;
display: inline-block;
position: relative;
top: 60px;
animation: pulse 1s linear infinite alternate;
-webkit-animation: pulse 1s linear infinite alternate;
}
.circle:after {
content: "";
display: inline-block;
height: 60px;
width: 60px;
border-radius: 50%;
background-color: none;
border-style: solid;
border-color: transparent;
border-top-color: #71cbcb;
border-bottom-color: #71cbcb;
border-width: 4px;
top: -9px;
left: -9px;
position: absolute;
animation: spinny 2s linear infinite;
-webkit-animation: spinny 2s linear infinite;
}
@keyframes spinny {
0% {
transform: scale(1) rotate(0deg);
-webkit-transform: scale(1) rotate(0deg);
}
50% {
transform: scale(1.2) rotate(180deg);
-webkit-transform: scale(1.2) rotate(180deg);
}
100% {
transform: scale(1) rotate(360deg);
-webkit-transform: scale(1) rotate(360deg);
}
}
@keyframes pulse {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600" rel="stylesheet">
<div class="container">
<p class="title">Spinner</p>
<div class="circle"></div>
</div>
我希望“脉冲”动画只影响内心圆而不是边框。对于边界,我使用:after
认为它将与实际圆圈分开,但我想这不是因为即使脉冲动画在.circle
而不是.circle:after
的css中仍然会影响它。
非常感谢任何帮助。我有点卡住了:D
答案 0 :(得分:1)
我在css中有相同的变化border-width:0px;
body {
background-color: #fafafa;
}
.container {
width: 700px;
height: 400px;
background-color: white;
margin: 0 auto;
box-shadow: 17px 17px 45px #d1d1d1;
text-align: center;
vertical-align: middle;
}
.title {
font-family: 'Open Sans', sans-serif;
font-weight: 600;
font-size: 180%;
text-align: center;
position: relative;
padding-top: 20px;
color: orangered;
}
.circle {
height: 50px;
width: 50px;
border-radius: 50%;
background-color: #d3e6e6;
margin: 10px;
display: inline-block;
position: relative;
top: 60px;
animation: pulse1 1s linear infinite alternate;
-webkit-animation: pulse1 1s linear infinite alternate;
}
.circle:after {
content: "";
display: inline-block;
height: 60px;
width: 60px;
border-radius: 50%;
background-color: none;
border-style: solid;
border-color: transparent;
border-top-color: #71cbcb;
border-bottom-color: #71cbcb;
border-width:4px;
top: -9px;
left: -9px;
position: absolute;
animation: spinny 2s linear infinite;
-webkit-animation: spinny 2s linear infinite;
}
@keyframes spinny {
0% {
transform: scale(1) rotate(0deg);
-webkit-transform: scale(1) rotate(0deg);
}
50% {
transform: scale(1.2) rotate(180deg);
-webkit-transform: scale(1.2) rotate(180deg);
}
100% {
transform: scale(1) rotate(360deg);
-webkit-transform: scale(1) rotate(360deg);
}
}
@keyframes pulse {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
@keyframes pulse1 {
0% {
opacity: 1;
}
100% {
opacity: 1;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Animation Spinner</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600" rel="stylesheet">
<style>
</style>
</head>
<body>
<div class="container">
<p class="title">Spinner</p>
<div class="circle"></div>
</div>
</body>
</html>