如何在<a> tag and disable link colour

时间:2015-06-04 13:40:36

标签: html css twitter-bootstrap font-awesome

I want to centre a font-awesome within an tag and disable the blu colour but so far I have not succeed in my aim. In addition I wish to have the icon a bit larger but the maximum size supported in font-awesome is 5x.

Could you please help me out with these issues Thanks

To reproduce the problem please visit the link below https://jsfiddle.net/z0vvpddf/

中集中字体真棒图标

HTML

   <div class="col-sm-4 portfolio-item ">
        <a href="<c:url value='/'></c:url>" class="portfolio-link" data-toggle="modal"> 
          <span class="caption"> 
              <span class="caption-content"> 
                <i>Wall</i>
              </span>
             </span> 
          <i class="fa fa-home fa-5x"></i>
        </a>
    </div>

CSS:

#portfolio .portfolio-item 
{
    right: 0;
    margin: 0 0 15px;
}

#portfolio .portfolio-item .portfolio-link 
{
    display: block;
    position: relative;
    margin: 0 auto;
    max-width: 400px;
}

#portfolio .portfolio-item .portfolio-link .caption 
{
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    background: #004DFA;
    -webkit-transition: all ease .5s;
    -moz-transition: all ease .5s;
    transition: all ease .5s;
}

#portfolio .portfolio-item .portfolio-link .caption:hover 
{
    opacity: 0.9;
}

#portfolio .portfolio-item .portfolio-link .caption .caption-content 
{
    position: absolute;
    top: 50%;
    width: 100%;
    height: 20px;
    margin-top: -12px;
    text-align: center;
    font-size: 20px;
    color: #fff;
}

#portfolio .portfolio-item .portfolio-link .caption .caption-content i 
{
    margin-top: -12px;
}

#portfolio .portfolio-item .portfolio-link .caption .caption-content h3,
#portfolio .portfolio-item .portfolio-link .caption .caption-content h4 
{
    margin: 0;
}

#portfolio * 
{
    z-index: 2;
}

@media(min-width:767px) 
{
    #portfolio .portfolio-item 
    {
        margin: 0 0 30px;
    }
}

img.displayed 
{
    display: block;
    margin-left: auto;
    margin-right: auto 
}

4 个答案:

答案 0 :(得分:3)

字体图标的控制方式与常规字体相同。您可以使用color font-sizetext-align css属性为您的目的设置样式,以及text-shadow和其他特定于文本的样式。

修改connexo的小提琴,删除悬停下划线并增加字体(图标)大小:

https://jsfiddle.net/4za5y63s/

答案 1 :(得分:2)

我会一次一个地回答你的问题:

  1. 如何使图标居中?我将以下CSS添加到您已有的选择器中。

    &#35;portfolio .portfolio-item .portfolio-link { text-align: center; }

    &#35;portfolio .portfolio-item .portfolio-link .caption { left: 0; }

    &#35;portfolio .portfolio-item .portfolio-link .caption .caption-content { left: 0; }

  2. 如何增加图标的大小?您可以通过设置font-size来创建自己的css来执行此操作。 Font-awesome使用em单位,因此.fa-5x只是5em

    .fa-7x { font-size: 7em; }

  3. 如何更改颜色?要更改<a>的颜色,

    &#35;portfolio .portfolio-item .portfolio-link { color: green; }

  4. 更改图标的颜色,

    `&#35;portfolio .portfolio-item .portfolio-link .fa {
        color: red;
    }`
    

答案 2 :(得分:1)

在这个小提琴中找到你的解决方案:https://jsfiddle.net/z0vvpddf/2/

#portfolio .portfolio-item .portfolio-link .fa-home {
    display: block;
    text-align: center;
    color: #000;
    z-index: -1;
}

答案 3 :(得分:0)

这样的事情:

#portfolio .portfolio-item .portfolio-link {color: #000;}
#portfolio .portfolio-item .portfolio-link:hover {color: #fff;}
#portfolio .portfolio-item .portfolio-link:hover .fa {font-size: 10em;} /* 10x */

小提琴:https://jsfiddle.net/praveenscience/z0vvpddf/1/

检查一下,可能是?

&#13;
&#13;
@import url("https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css");
@import url("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css");
.portfolio-link, .portfolio-link:hover {color: #000;}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div class="container-fluid">
  <div class="row-fluid">
    <div class="col-md-2 col-md-offset-4">
      <a href="#" class="portfolio-link" data-toggle="modal">
        <span class="caption pull-right"> 
          <span class="caption-content">Wall</span>
        </span> 
        <i class="fa fa-home fa-5x"></i>
      </a>
    </div>
  </div>
</div>
&#13;
&#13;
&#13;