字体真棒动画锭床工人通过背景

Sat*_*tAj 34 css3 font-awesome-3.2

我通过CSS背景使用字体真棒旋转图标来加载页面.

    /* Styles go here */
.loading-icon {
  position: relative;
  width: 20px;
  height: 20px; 
  margin:50px auto;
}

.loading-icon:before {
  content: "\f110";
  font-family: FontAwesome;
  font-size:20px;
  position: absolute;
  top: 0; 
}
Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html>
<html>

<head>
  <link data-require="fontawesome@*" data-semver="4.5.0" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.css" />
  <link rel="stylesheet" href="style.css" />
</head>

<body>
  <div class="loading-icon"></div>
</body>

</html>
Run Code Online (Sandbox Code Playgroud)

图标在页面中成功呈现,但它是静态的.如何使用字体真棒作为背景的动画旋转图标?请帮助.

Ber*_*hot 50

你应该用fa fa-spinner fa-spin.

请参阅:Font Awesome示例

例:

/** CSS **/
@import url('https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.css');
Run Code Online (Sandbox Code Playgroud)
<!-- HTML -->
<div class="fa fa-spinner fa-spin"></div>
Run Code Online (Sandbox Code Playgroud)

  • &lt;div class =“ fa fa-spinner fa-spin”&gt; &lt;/ div&gt;可以工作。但是我想使用我的问题中所述的font-awesome图标作为CSS背景。 (2认同)

Sat*_*tAj 28

正确答案:更新CSS,如下所示.

    /* Styles go here */
.loading-icon {
  position: relative;
  width: 20px;
  height: 20px; 
  margin:50px auto;
  -webkit-animation: fa-spin 2s infinite linear;
  animation: fa-spin 2s infinite linear;
}

.loading-icon:before {
  content: "\f110";
  font-family: FontAwesome;
  font-size:20px;
  position: absolute;
  top: 0; 
}
Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html>
<html>

<head>
  <link data-require="fontawesome@*" data-semver="4.5.0" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.css" />
  <link rel="stylesheet" href="style.css" />
</head>

<body>
  <div class="loading-icon"></div>
</body>

</html>
Run Code Online (Sandbox Code Playgroud)


Luc*_*nte 19

字体真棒4.7

__CODE__ base font-awesome类

__CODE__ 使用哪种旋转器设计

__CODE__ 旋转图标

__CODE__ 只是增加图标的大小

__CODE__ 只是固定图标

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>

<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i>
<i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw"></i>
<i class="fa fa-refresh fa-spin fa-3x fa-fw"></i>
<i class="fa fa-cog fa-spin fa-3x fa-fw"></i>
<i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>
Run Code Online (Sandbox Code Playgroud)

字体真棒5+

__CODE__ 只是增加了图标的大小

__CODE__ solid-awesome基类,用于实体图标

__CODE__ 使用哪种旋转器设计

__CODE__ 旋转图标

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">

<div class="fa-3x">
  <i class="fas fa-spinner fa-spin"></i>
  <i class="fas fa-circle-notch fa-spin"></i>
  <i class="fas fa-sync fa-spin"></i>
  <i class="fas fa-cog fa-spin"></i>
  <i class="fas fa-spinner fa-pulse"></i>
  <i class="fas fa-stroopwafel fa-spin"></i>
</div>
Run Code Online (Sandbox Code Playgroud)

Font Awesome 5 Spinner文档:

https://fontawesome.com/how-to-use/on-the-web/styling/animating-icons

Font Awesome 5 Spinner图标列表:

https://fontawesome.com/icons?c=spinners

  • 这不能回答问题。您所要做的只是列出旋转图标的方法,您可以在FA的文档页面上找到这些图标。OP正在询问与`:before`一起使用时如何旋转图标 (2认同)