发布于 2018-10-01 05:44:39
通过使用渐变颜色和两个图标,我们可以实现这一点,但它仍然是一种老生常谈的方式,你需要具体处理每种情况(图标+着色):
.fa-google path{
fill:url(#grad1);
}
.fa-google + .fa-google path{
fill:url(#grad2);
}
.icon {
display:inline-block;
position:relative;
}
.fa-google + .fa-google {
position:absolute;
left:0;
top:0;
clip-path: polygon(0% 0%,120% 0%,0% 75%);
}<script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js" ></script>
<svg style="width:0;height:0;">
<defs>
<linearGradient id="grad1" x1="0%" y1="30%" x2="50%" y2="0%">
<stop offset="50%" stop-color="#34a853" />
<stop offset="50%" stop-color="#4285f4" />
</linearGradient>
<linearGradient id="grad2" x1="0%" y1="30%" x2="50%" y2="0%">
<stop offset="50%" stop-color="#fbbc05" />
<stop offset="50%" stop-color="#ea4335" />
</linearGradient>
</defs>
</svg>
<div class="icon">
<i class="fab fa-google fa-7x"></i>
<i class="fab fa-google fa-7x"></i>
</div>
我们也可以考虑使用带有一个图标的conic-gradient()。同样,它是特定于此特定情况的:
.fa-google {
background: conic-gradient(from -45deg, #ea4335 110deg, #4285f4 90deg 180deg, #34a853 180deg 270deg, #fbbc05 270deg) 73% 55%/150% 150% no-repeat;
-webkit-background-clip: text;
background-clip: text;
color: transparent;
-webkit-text-fill-color: transparent;
}<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.12.0/css/all.css">
<i class="fab fa-google fa-10x"></i>
<i class="fab fa-google fa-6x"></i>
<i class="fab fa-google fa-3x"></i>

上面的方法并不适用于所有的浏览器,所以你可以考虑多个linear-gradient,如下所示:
.fa-google {
background:
linear-gradient(to bottom left,transparent 49%,#fbbc05 50%) 0 25%/48% 40%,
linear-gradient(to top left,transparent 49%,#fbbc05 50%) 0 75%/48% 40%,
linear-gradient(-40deg ,transparent 53%,#ea4335 54%),
linear-gradient( 45deg ,transparent 46%,#4285f4 48%),
#34a853;
background-repeat:no-repeat;
-webkit-background-clip: text;
background-clip: text;
color: transparent;
-webkit-text-fill-color: transparent;
}
/*#fbbc05*/<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.12.0/css/all.css">
<i class="fab fa-google fa-10x"></i>
<i class="fab fa-google fa-6x"></i>
<i class="fab fa-google fa-3x"></i>
发布于 2018-09-30 22:42:20
使用FontAwesome (或任何其他可用的图标字体)都无法做到这一点--也就是说,修改字体并在您创建的部分图标字符的基础上创建您自己的自定义HTML和CSS。
将每个图标颜色的部分分别创建为一个角色,并将它们堆叠在一起。该示例堆叠了两个现有的FA-图标,以显示该技术:
.stack-icons {
position: absolute;
}
.stack-icons i[class*=fa-] {
position: absolute;
color: orange;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.stack-icons i[class*=fa-]+i[class*=fa-] {
color: #a00;
}<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<div class="stack-icons">
<i class="far fa-circle"></i>
<i class="fas fa-angle-up"></i>
</div>
发布于 2021-04-23 18:35:58
.fa-google-g-new {
background: conic-gradient(from -45deg, #ea4335 110deg, #4285f4 90deg 180deg, #34a853 180deg 270deg, #fbbc05 270deg) 72% 54%/151% 151% no-repeat;
-webkit-background-clip: text;
background-clip: text;
color: transparent;
-webkit-text-fill-color: transparent;
}
use this class .fa-google-g-new as new with font awesomhttps://stackoverflow.com/questions/52578726
复制相似问题