我使用 Font Aewsome 作为我的社交图标,并使用 Bootstrap 3。

我想要一个像底部这样的悬停效果: 例子

我有一个社交图标列表:

<ul class="social-buttons">
    <li class="youtube"><a href="#" title="Follow us on Youtube"><i class="fa fa-youtube fa-lg"></i></a></li>
    <li class="twitter"><a href="#" title="Follow us on Twitter"><i class="fa fa-twitter fa-lg"></i></a></li>
    <li class="xing"><a href="#" title="Follow us on Xing"><i class="fa fa-xing fa-lg"></i></a></li>
    <li class="rss"><a href="#" title="Check out our RSS"><i class="fa fa-rss fa-lg"></i></a></li>
</ul>

对于我的CSS我有这个:

.social-buttons {
  position: absolute;
  left: 70%;
  top: 6px;
}

.social-buttons li {
  list-style-type: none;
  float: left;
  margin: 9px 9px 9px 9px;
  position: relative;
}

.social-buttons li a {
  padding: 2px 2px 2px 2px;
  display: block;
}

.social-buttons-footer {
  position: relative;
  left: -49px;
}

.social-buttons-footer li {
  list-style-type: none;
  float: left;
  margin: 8px 8px 8px 8px;
}

.social-buttons-footer li a {
  padding: 2px 2px 2px 2px;
  display: block;
}

.fa-youtube, .fa-twitter, .fa-xing, .fa-rss {
  color: #000000;
}
.fa-lg:hover{
  color: #ffffff;
}

.fa-2x{
  color: #000000;
}
.fa-2x:hover{
  color: #ffffff;
}


// Hover Effect ---------------------------------------------------------------------------------------------------------------------------------------------
.youtube a:hover{
  background-color: #db2c2c;
  -webkit-animation: toBottomFromTop 0.3s;
  -moz-animation: toBottomFromTop 0.3s;
  animation: toBottomFromTop 0.3s;
  color: #ffffff;
}

.twitter a:hover{
  background-color: #83d0f5;
  -webkit-transition: all ease 0.3s;
  -moz-transition: all ease 0.3s;
  -ms-transition: all ease 0.3s;
  -o-transition: all ease 0.3s;
  transition: all ease 0.3s;
}

.xing a:hover{
  background-color: #a2d123;
  -webkit-transition: all ease 0.3s;
  -moz-transition: all ease 0.3s;
  -ms-transition: all ease 0.3s;
  -o-transition: all ease 0.3s;
  transition: all ease 0.3s;
}

.rss a:hover{
  background-color: #fe9c01;
  -webkit-transition: all ease 0.3s;
  -moz-transition: all ease 0.3s;
  -ms-transition: all ease 0.3s;
  -o-transition: all ease 0.3s;
  transition: all ease 0.3s;
}

在过去的几个小时里我搜索了谷歌,我只能找到他们使用精灵或类似的东西的例子。我真的不知道该怎么做。我应该把悬停时应该交换的图标放在哪里?我知道如何用精灵来做到这一点 - 我在那里使用这个位置。但我在这里该如何使用它呢?我为 YouTube 悬停尝试了其他方法:但这看起来像是一个大错误!有人可以教我或告诉我在哪里可以找到图吗?会好的。

有帮助吗?

解决方案

你需要的效果我已经搭建好了 在 JsFiddle 上.

您现在只需添加 AwsomeFont 项目即可。

我已经添加了 overflow: hidden; 给父母并移动单个元素 margin: -x px 0 0 0 在悬停事件上。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top