css - 使用 CSS 定位动画图标并移除重叠

标签 css html twitter-bootstrap font-awesome

我试图将图标放在右边,将标签放在中间。 我的网站使用的是 BootStrap 和 Font-Awesome。以下是 HTML:

<div class="row">
  <div class="col-lg-12" style="text-align: center">
    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Health</span>
    </a>
    <span>&nbsp;</span>
    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Fitness</span>
    </a>
    <span>&nbsp;</span>
    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Safety</span>
    </a>
    <span>&nbsp;</span>
    <i class="fa fa-heart faa-pulse animated" style="float:right;"></i>&nbsp;&nbsp;&nbsp;
    <i class="fa fa-star faa-pulse animated" style="float:right;"></i>&nbsp;&nbsp;&nbsp;
    <i class="fa fa-smile-o faa-pulse animated" style="float:right;"></i>
  </div>
</div>
<div class="row">
  <div class="col-lg-12">
    <h1 class="post-header" style="text-align: center">This is the header</h1>
  </div>
</div>

CSS:

@keyframes pulse {
  0% {
    -webkit-transform: scale(1.1);
    -ms-transform: scale(1.1);
    transform: scale(1.1);
  }

  50% {
    -webkit-transform: scale(0.8);
    -ms-transform: scale(0.8);
    transform: scale(0.8);
  }

  100% {
    -webkit-transform: scale(1.1);
    -ms-transform: scale(1.1);
    transform: scale(1.1);
  }
}

.faa-pulse.animated,
.faa-pulse.animated-hover:hover,
.faa-parent.animated-hover:hover > .faa-pulse {
  -webkit-animation: pulse 2s linear infinite !important;
  animation: pulse 2s linear infinite !important;
  font-size:1.8em;  
}
.fa-heart {
    color: red !important;
}
.fa-star {
    color: gold !important;
}
.fa-smile-o {
  color: deeppink !important;
}

问题是我的图标在动画过程中相互重叠,标签没有与中心对齐。此外,图标之间的空间非常小。我该如何解决这个问题?

这是 demo

最佳答案

试试这个:

<div class="row">
  <div class="col-lg-12 text-center">
    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Health</span>
    </a>

    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Fitness</span>
    </a>

    <a href="#" style="text-decoration: none;">
      <span style="background-color: #171717; color: #FFF; padding: 2px">Safety</span>
    </a>
    <span class="animated-icons"> 
    <i class="fa fa-heart faa-pulse animated"></i>
    <i class="fa fa-star faa-pulse animated" ></i>
    <i class="fa fa-smile-o faa-pulse animated" ></i>
    </span>

  </div>
</div>

CSS:

.animated-icons {
  position: absolute;
  right: 15px;
}

关于css - 使用 CSS 定位动画图标并移除重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44382044/

相关文章:

css - Twitter Bootstrap - 导航没有响应?

css - 在 PHP 中的重复渐变图像之上添加图像

iphone - 使用css,html在iphone webview中的屏幕中央显示图像

html - 如何修复 Safari 中的 flex 50% 布局问题?

javascript - 如何扩展 localStorage

jquery - 如何更新包含另一个在函数中更新的变量的全局变量

java - 网页表单提交数量有限

javascript - Bootstrap 动画不起作用

css - 如何阻止文本与 CSS 重叠?

ruby-on-rails - 使用 bootstrap 和 rails 的多列