如何让字体超棒的微调器绕着圆形图片转
How to make a font-awesome spinner go around a circular picture
我在 div
标签中放置了一个圆形图像。现在我想在这张图片上放置一个超棒的字体微调器。
我正在寻找的效果是制作旋转图像边框,例如 this spinner icon。
微调器和图像必须具有相同的半径。
解决方案可以在没有字体超棒的微调器的情况下进行,但使用纯 CSS3。
使用:
<i class="fa fa-spinner fa-circle-o-notch"><img href="your-image" id="image"></img></i>
并将此添加到您的 css:
#image {
display: inline;
}
Font Awesome 可以为您完成这项工作,但如果您希望任何 HTML 元素无限旋转,您可以使用 @keyframes
rule—supplemented by @-webkit-keyframes
for Safari support—to define the rotating behavior. Use the animation
property 将此行为应用于 HTML元素.
下面的代码片段定义了 rotating
动画并将其应用于 .circle
。 .circle
元素和图像放置在 position: absolute
中,因此圆圈围绕着图像。
@-webkit-keyframes rotating {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
@keyframes rotating {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.circle {
animation: rotating 2.5s linear infinite;
position: absolute;
left: -15px;
top: -15px;
}
#demo {
padding: 40px;
color: #222;
margin: 40px;
position: relative;
font-size: 130px;
}
#demo img {
border-radius: 50%;
width: 100px;
height: 100px;
position: absolute;
left: 0;
top: 0;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<div id="demo">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS_Fe2cRDzAEE4mE5DDxYsbx9Emt2aQYVs-kmsDnOc8PeHOSlYV" />
<div class="circle fa fa-circle-o-notch"></div>
</div>
我在 div
标签中放置了一个圆形图像。现在我想在这张图片上放置一个超棒的字体微调器。
我正在寻找的效果是制作旋转图像边框,例如 this spinner icon。
微调器和图像必须具有相同的半径。
解决方案可以在没有字体超棒的微调器的情况下进行,但使用纯 CSS3。
使用:
<i class="fa fa-spinner fa-circle-o-notch"><img href="your-image" id="image"></img></i>
并将此添加到您的 css:
#image {
display: inline;
}
Font Awesome 可以为您完成这项工作,但如果您希望任何 HTML 元素无限旋转,您可以使用 @keyframes
rule—supplemented by @-webkit-keyframes
for Safari support—to define the rotating behavior. Use the animation
property 将此行为应用于 HTML元素.
下面的代码片段定义了 rotating
动画并将其应用于 .circle
。 .circle
元素和图像放置在 position: absolute
中,因此圆圈围绕着图像。
@-webkit-keyframes rotating {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
@keyframes rotating {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.circle {
animation: rotating 2.5s linear infinite;
position: absolute;
left: -15px;
top: -15px;
}
#demo {
padding: 40px;
color: #222;
margin: 40px;
position: relative;
font-size: 130px;
}
#demo img {
border-radius: 50%;
width: 100px;
height: 100px;
position: absolute;
left: 0;
top: 0;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<div id="demo">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS_Fe2cRDzAEE4mE5DDxYsbx9Emt2aQYVs-kmsDnOc8PeHOSlYV" />
<div class="circle fa fa-circle-o-notch"></div>
</div>