html - Font Awesome 图标悬停在文本之外

标签 html css twitter-bootstrap font-awesome

我正在使用很棒的字体图标来伴随导航栏中的列表项,如下所示:

                    <li class="page-scroll">
                    <a href="#"><i class="fa fa-clock-o"></i> Latest</a>
                </li>

CSS:

.navbar .navbar-nav li a {
    color:#f0f0f0;
    -webkit-transition: all ease 1s;
    -moz-transition: all ease 1s;
    transition: all ease 1s;
}

.navbar .navbar-nav li a:hover {
    color:#7dbd83;
    -webkit-transition: all ease 1s;
    -moz-transition: all ease 1s;
    transition: all ease 1s;
}

我已经尝试了一些方法,例如制作一个单独的 CSS 仅包含 i 和 i:hover 并且独立于文本更改悬停颜色。我也试过在 a 之后在下面的 css 中包含 i 和 i:hover,但这完全破坏了效果。

如何让图标在悬停时与文本同时改变颜色?

最佳答案

 <html>
 <head>
 <script>

 </script>
 <style>

.animate_it{
 color:#f0f0f0;
 -webkit-transition: color 2s;
 -moz-transition: color 2s;
 transition:color 2s;
  }

  .animate_it:hover{
  color:#7dbd83;
  -webkit-transition: color 2s;
  -moz-transition: color 2s;
   transition: color 2s;
  }
  </style>
  </head>
   <body>
               <li class="page-scroll">
                <a href="#"><i class="animate_it" > Latest</i></a>
                </li>
  </body>
  </html>

关于html - Font Awesome 图标悬停在文本之外,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33185414/

相关文章:

css - Magento 自定义 css 被父 css 覆盖 - 使用 local.xml

jquery - 使用 jQuery 更改绝对定位元素的位置

javascript - Bootstrap 位于 DOM 中的什么位置

css - wordpress bootstrap 导航栏下拉菜单不起作用

html - Bootstrap 折叠表

jquery - 加载整个页面后加载功能

html - "infamous"CSS : 2 divs side-by-side, 跨浏览器版本(?)

javascript - 使用下拉菜单显示特定的数据表

css - 如何更改网页上特定部分的颜色?

javascript - Facebook 如何将工具栏保留在页面底部?