twitter-bootstrap font-awesome 图标背景可以透明吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23778391/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 20:45:38  来源:igfitidea点击:

Can font-awesome icon background be transparent?

csstwitter-bootstrapfontsfont-awesome

提问by Paul Preibisch

I am using a font awesome "x" icon - but it has a white background - can font-awesome backgrounds be transparent?

我正在使用字体很棒的“x”图标 - 但它有一个白色背景 - 字体很棒的背景可以是透明的吗?

The reason is, I want to display it over an image. What option do I need to do this?

原因是,我想在图像上显示它。我需要什么选项才能做到这一点?

Current Code is:

当前代码是:

 <i class="fa fa-times fa- m-n"></i>

回答by SW4

Yes, font awesome uses the ::beforepsuedo for its icons, so simply do, e.g.:

是的,font awesome 使用::before伪作为其图标,所以只需这样做,例如:

Demo Fiddle

演示小提琴

i::before{
    background:transparent;
}

That said, you will likely want to use more specificity than simply i, e.g.:

也就是说,您可能希望使用比简单更多的特异性i,例如:

i[class*=fa-times]::before{
   background:transparent;
}