【问题标题】:How to make a font-awesome spinner go around a circular picture如何让字体很棒的微调器绕着圆形图片旋转
【发布时间】:2015-09-07 03:15:53
【问题描述】:

我在div 标记中放置了一个圆形图像。现在我想在这张图片上放置一个字体很棒的微调器。

我正在寻找的效果是制作旋转图像边框,例如this spinner icon

微调器和图像必须具有相同的半径。

解决方案可以不用字体超棒的微调器,但使用纯 CSS3。

【问题讨论】:

  • 到目前为止你能发布你的代码吗?还是小提琴?

标签: html css spinner font-awesome


【解决方案1】:

Font Awesome 可以为您完成这项工作,但如果您希望任何 HTML 元素无休止地旋转,您可以使用 @keyframes rule(由 @-webkit-keyframes 补充以支持 Safari)来定义旋转行为。使用 animation property 将此行为应用于 HTML 元素。

下面的 sn-p 定义了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>

【讨论】:

  • Chrome 现在正在使用无前缀属性
【解决方案2】:

用途:

<i class="fa fa-spinner fa-circle-o-notch"><img href="your-image" id="image"></img></i>

并将其添加到您的 css 中:

#image {
    display: inline;
}

examples 并显示docs

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-02
    • 2015-04-18
    • 1970-01-01
    • 1970-01-01
    • 2021-05-04
    • 2017-12-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多