Fontawesome 品牌图标背后的彩色背景
Coloured Background Behind Fontawesome Brand Icon
我的网站上有许多很棒的品牌图标,我将它们用作 link 到其他各种网站。
我已经成功地设计了这些品牌图标的样式,使其与鼠标悬停时的品牌颜色相匹配,但我完全坚持使用一个,尤其是 Flickr。
目前我用渐变背景显示它,一半是蓝色一半是粉红色,但我对它不是很满意。
我真正想要的是唯一可见的颜色应该是蓝色,rgb(0,99,220),围绕在 Flickr 品牌图标的外面,但图标后面的背景应该是 blue/pink 渐变等悬停图标中的两个孔显示为左孔蓝色和右孔粉红色。
我试图通过使背景与图标大小相同并使用渐变然后在背景周围环绕 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>
如有任何帮助,我们将不胜感激
问候..,
终于用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>
通过删除不必要的代码和将粉红色区域减少到仅需要的最小值来减小文件大小。
我的网站上有许多很棒的品牌图标,我将它们用作 link 到其他各种网站。
我已经成功地设计了这些品牌图标的样式,使其与鼠标悬停时的品牌颜色相匹配,但我完全坚持使用一个,尤其是 Flickr。
目前我用渐变背景显示它,一半是蓝色一半是粉红色,但我对它不是很满意。
我真正想要的是唯一可见的颜色应该是蓝色,rgb(0,99,220),围绕在 Flickr 品牌图标的外面,但图标后面的背景应该是 blue/pink 渐变等悬停图标中的两个孔显示为左孔蓝色和右孔粉红色。
我试图通过使背景与图标大小相同并使用渐变然后在背景周围环绕 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>
如有任何帮助,我们将不胜感激
问候..,
终于用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>
通过删除不必要的代码和将粉红色区域减少到仅需要的最小值来减小文件大小。