php - 如何在elementor中添加自定义小部件ICON
问题描述
我正在为Wordpress中的Elementor编辑器开发一个自定义小部件。
我想设置自定义小部件 ICON,Elementor 提供了 get_icon 函数,因为我们必须返回具有 :before 伪元素的类并在浏览器中呈现。
有没有办法使用 png 或任何其他格式将 ICON 更新为 Elementor 小部件。
即使我尝试使用内容为空和背景图像的类。它不工作。
在 Elementor 中创建自定义小部件的文档: https ://developers.elementor.com/creating-a-new-widget/
提前致谢。
解决方案
以下可以作为解决方案。
添加了一个类并为该类应用背景图像。下面是css片段。
.elementor-element .icon .class-name:before {
content: "";
background-image: url(logo-name.png);
height: 30px;
display: block;
background-size: contain;
background-repeat: no-repeat;
background-position: center center;
}
但问题是,它不支持 Elementor 中的 Light 和 Drak 背景。
相反,您可以从 SVG 文件创建字体,并使用 @font-face 创建自己的字体系列。
定义字体系列并使用它
@font-face {
font-family: 'aweber-font';
}
.logo {
font-family: 'aweber-font' !important;
}
.logo:before {
content: 'value';
}
推荐阅读
- python-3.x - 如何使用python3将(.csv)csv文件中的内容/数据复制到(.xlsx)excel文件?
- android - 如何更改 Spinner 的字体系列?
- visual-studio - Visual Studio 2017 中的“在文件中查找”不起作用
- java - 如何使用java(spring boot)以json格式检索完整值(带小数的大整数值)?
- akavache - 在仅 aot 模式下运行时尝试 JIT 编译方法“Akavache.Sqlite3.Registrations:Register (Splat.IMutableDependencyResolver)”
- python - 字典在python中按月天数(键)排序
- bash - bash 等效于 zsh 的 '=' 命令路径扩展?
- reactjs - Reactadmin - 编辑用户角色
- java - 在 Spring Boot 中启动应用程序上下文时出错
- android - Android - Firebase Crashlytics - “无法检索设置”