简体   繁体   English

如何用基于字体的图标(Font Awesome / Ion)替换SVG图标?

[英]How to replace an SVG icon with a font based icon (Font Awesome/Ion)?

I'm having a dropdown list that shows an SVG icon whereas all the other ones show a button with a font-based icon (in this case ion-icon). 我有一个显示SVG图标的下拉列表,而其他所有列表则显示带有基于字体的图标的按钮(在本例中为ion-icon)。 Of course I want all dropdown lists to look the same. 当然,我希望所有下拉列表看起来都一样。

I've tried modifying the CSS code and looked through some .js and .php files but nothing was successfull. 我尝试修改CSS代码并浏览了一些.js和.php文件,但没有成功。

Code of the SVG icon SVG图标的代码

<svg class="dd__expandIcon" viewBox="0 0 9 15" width="9px" height="15px">
    <path d="M315,1318.04l-4.5,4.96-4.5-4.96,0.944-1.04,3.557,3.92,3.553-3.92,0.944,1.04m-9-5.08,4.5-4.96,4.5,4.96-0.944,1.04-3.557-3.92-3.553,3.92L306,1312.96" transform="translate(-306 -1308)"></path>
</svg>
.dd__expandIcon {
    width: 9px;
    height: 15px;
    flex-shrink: 0;
    fill: #bdbdbd;
    margin-left: 10px
}

Code of the ion-icon 离子图标代码

<button type="button" class="reactiveToggleBtn___cQAWH">
    <i class="ion-chevron-down"></i>
</button>
.reactiveToggleBtn___cQAWH i {
    font-size: 13px;
    color: #484848;
}

You can directly see the actual result (dropdown "Thème de la séance") vs expected result (all other dropdowns) here: site 您可以在此处直接查看实际结果(“Thèmede laséance”下拉列表)与预期结果(所有其他下拉列表)的对比:site

Thanks for your help! 谢谢你的帮助!

I was finally able to find a way to make the trick. 我终于找到了解决问题的办法。

Hide the svg: 隐藏svg:

svg.dd__expandIcon {visibility:hidden;}

Add a background image to the selectbox 将背景图像添加到选择框

.dd__selectControl {background: #f1f1f1 url('/wp-content/uploads/dropdown2.png') right no-repeat!important;}

Maybe not the proper way to do it but as said, it makes the trick. 也许不是执行此操作的正确方法,但如上所述,它可以解决问题。

You can convert SVG icon file into Font base icon using 您可以使用以下方式将SVG图标文件转换为Font base图标

https://icomoon.io/app https://icomoon.io/app

  1. Import Icons 导入图标
  2. Select icons which you want to convert 选择要转换的图标
  3. Click on generate font 点击生成字体

For more info check below link : How to convert .svg files to a font? 有关更多信息,请参见下面的链接: 如何将.svg文件转换为字体?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM