2016-05-01 30 views
2

我在我的網站上有很多fontawesome品牌圖標,我用它作爲各種其他網站的鏈接。Fontawesome品牌圖標背後的彩色背景

我設法將這些品牌圖標設置爲與懸停時的品牌顏色相匹配,但我完全停留在一個特殊的Flickr中。

暫時我用漸變背景顯示了它,一半藍色的&,但我對它不是很滿意。

我真正想要的是唯一可見的顏色應該是Flickr品牌圖標外部的藍色rgb(0,99,220),但是直接位於圖標後面的背景應該是藍色/粉色漸變將鼠標懸停在圖標中的兩個孔顯示爲左孔藍色&右孔粉紅色。

我試圖通過使背景具有與圖標相同的尺寸來實現此目的,並使用漸變,然後在背景周圍包裹8px藍色邊框,但我無法使其工作,一切似乎都不符合對齊方式看起來很糟糕。

我已經削減了HTML & css只包括在這裏張貼需要的部分。

/* Renaming of FONT AWESOME fonts */ 
 

 
.soc-flkr:before { 
 
    content: "\f16e"; 
 
} 
 
/* Footer Social Buttons */ 
 

 
ul.soc-icns { 
 
    list-style: none; 
 
    display: block; 
 
    float: left; 
 
    margin-top: 2px; 
 
    margin-bottom: 0px; 
 
    margin-left: 10px; 
 
    padding-left: 0px; 
 
} 
 
ul.soc-icns li { 
 
    display: inline; 
 
} 
 
/* Footer Section Icons */ 
 

 
.soc-icns a.socFlickr:hover { 
 
    background: rgb(0, 99, 220); 
 
    background: -moz-linear-gradient(left, rgb(0, 99, 220) 0%, rgb(0, 99, 220) 50%, rgb(255, 0, 132) 50%, rgb(255, 0, 132) 100%); 
 
    background: -webkit-linear-gradient(left, rgb(0, 99, 220) 0%, rgb(0, 99, 220) 50%, rgb(255, 0, 132) 50%, rgb(255, 0, 132) 100%); 
 
    background: linear-gradient(to right, rgb(0, 99, 220) 0%, rgb(0, 99, 220) 50%, rgb(255, 0, 132) 50%, rgb(255, 0, 132) 100%); 
 
    -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#0063dc', endColorstr='#ff0084',GradientType=1)"; 
 
    border: 1px solid rgb(201, 201, 201); 
 
} 
 
.soc-icns a.socFlickr:hover i { 
 
    color: rgb(255, 255, 255); 
 
} 
 
.soc-sq li a { 
 
    display: inline-block; 
 
    position: relative; 
 
    margin: 0 auto 0 auto; 
 
    -moz-border-radius: 5px; 
 
    -webkit-border-radius: 5px; 
 
    border-radius: 5px; 
 
    text-align: center; 
 
    width: 24px; 
 
    height: 24px; 
 
    font-size: 16px; 
 
    border: 1px solid rgb(141, 141, 141); 
 
    line-height: 24px; 
 
    color: rgb(141, 141, 141); 
 
    vertical-align: middle; 
 
} 
 
.soc-sq li i { 
 
    margin-top: 0px; 
 
} 
 
.soc-sq li a:hover i, 
 
.triggeredHover { 
 
    -moz-transform: rotate(360deg); 
 
    -webkit-transform: rotate(360deg); 
 
    -ms--transform: rotate(360deg); 
 
    transform: rotate(360deg); 
 
    -webkit-transition: all 0.2s; 
 
    -moz-transition: all 0.2s; 
 
    -o-transition: all 0.2s; 
 
    -ms-transition: all 0.2s; 
 
    transition: all 0.2s; 
 
} 
 
.soc-sq i { 
 
    -webkit-transition: all 0.8s; 
 
    -moz-transition: all 0.8s; 
 
    -o-transition: all 0.8s; 
 
    -ms-transition: all 0.8s; 
 
    transition: all 0.8s; 
 
} 
 
.soc-icns a { 
 
    background-color: rgb(201, 201, 201); 
 
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css" rel="stylesheet"> 
 

 

 
<div> 
 
    <ul class="soc-icns soc-sq"> 
 
    <li><a href="https://www.flickr.com" target="_blank" class="socFlickr" title="Flickr"><i class="fa soc-flkr"></i></a> 
 
    </li> 
 
    </ul> 
 
</div>

任何幫助,將不勝感激

問候..,

回答

0

使用SVG-edit

SVG的代碼看起來像這樣最後解決了這個:

<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> 
<!-- Created with SVG-edit - http://svg-edit.googlecode.com/ --> 
<g> 
    <title>Flickr Background</title> 
    <rect id="Blue" height="24" width="24" x="0" y="0" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="0" stroke="#000000" fill="#0063dc"/> 
    <rect id="Pink" height="12" width="6" x="12" y="6" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="0" stroke="#000000" fill="#ff0084" rx="5" ry="5"/> 
</g> 
</svg> 

我保存這個作爲flickr.svg然後從改變我目前的CSS文件:

.soc-icns a.socFlickr:hover { 
    background: rgb(0, 99, 220); 
    background: -moz-linear-gradient(left, rgb(0, 99, 220) 0%, rgb(0, 99, 220) 50%, rgb(255, 0, 132) 50%, rgb(255, 0, 132) 100%); 
    background: -webkit-linear-gradient(left, rgb(0, 99, 220) 0%, rgb(0, 99, 220) 50%, rgb(255, 0, 132) 50%, rgb(255, 0, 132) 100%); 
    background: linear-gradient(to right, rgb(0, 99, 220) 0%, rgb(0, 99, 220) 50%, rgb(255, 0, 132) 50%, rgb(255, 0, 132) 100%); 
    -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#0063dc', endColorstr='#ff0084',GradientType=1)"; 
    border: 1px solid rgb(201, 201, 201); 
} 

到:

.soc-icns a.socFlickr:hover 
{ 
    background: url(flickr.svg); 
    border: 1px solid rgb(201,201,201); 
} 

和它的作品就像一個夢。

這裏的工作Fiddle

我以前從未使用過SVG,但它似乎使用&很簡單似乎比CSS更加直觀。

希望這答案幫助別人。

問候..,

只是一個小更新到SVG代碼

<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> 
<g> 
    <title>Flickr Background</title> 
    <rect id="Blue" height="24" width="24" x="0" y="0" fill="#0063dc"/> 
    <rect id="Pink" height="4" width="4" x="12" y="10" fill="#ff0084"/> 
    </g> 
</svg> 

通過移除減少粉紅面積只有所需的最低不必要的代碼&減小文件大小。