Fontawesome品牌图标背后的彩色背景

时间:2016-05-01 13:59:24

标签: html css css3 font-awesome

我的网站上有许多令人遗憾的品牌图标,我用它作为其他各种网站的链接。

我设法将这些品牌图标设计为与悬停时的品牌颜色相匹配,但我完全坚持使用Flickr。

暂时我用渐变背景显示它,半蓝&半粉红色,但我对它不是很满意。

我真正想要的是,唯一可见的颜色应该是蓝色,rgb(0,99,220),围绕Flickr品牌图标的外部,但是图标后面的背景应该是蓝色/粉红色渐变等等将图标显示中的两个孔悬停为左孔蓝色&右孔粉红色。

我试图通过使背景与图标大小相同来实现这一点,并使用渐变然后在背景周围包裹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>
&#13;
&#13;
&#13;

非常感谢任何帮助

问候...,

1 个答案:

答案 0 :(得分: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,但使用起来非常简单&amp;它似乎比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>

通过删除不必要的代码减少文件大小&amp;将粉红色区域减少到所需的最小值。