duankui3838 2018-03-02 10:18
浏览 131
已采纳

树枝模板中的SVG图标

I'm struggling with svg icons. I'm creating menu and to do this I have to use several of svg icons. I already know, that if I want to manipulate colour with help CSS (for example when icon is active/hover) I have to use in HTML <svg> tag not <img src="path-to-icon.svg"/>. How can I solve this problem in a nice way?

I don't want use full path of svg in my HTML file, because sometimes it is has a hundred of lines d="..." attribute. I try to avoid use <use xlink:href="path-to-icon.svg" /> as well, because is not supported by IE or Edge browsers.

I can add that I use .twig template, so maybe there is a 'PHP' way to add icon.

HTML:

  <label id="menuIcon" for="menu" onclick="openNav()">
          {# svg icon #}
  </label>

CSS

.icon:hover path {
    fill: green;
}
  • 写回答

1条回答 默认 最新

  • duanbi3385 2018-03-02 10:37
    关注

    I would generate my own font file with all the icons used in the application... just like fontawesome or ionicons.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 全书网Java爬取数据
  • ¥15 SAP HANA SQL Script 。SUM OVER 怎么加where
  • ¥15 怎么获取红包封面的原始链接,并且获取红包封面序列号
  • ¥100 微信小程序跑脚本授权的问题
  • ¥60 为什么使用python对地震数据进行umap降维后,数据成图会出现不连续的现象
  • ¥100 房产抖音小程序苹果搜不到安卓可以付费悬赏
  • ¥15 STM32串口接收问题
  • ¥15 腾讯IOA系统怎么在文件夹里修改办公网络的连接
  • ¥15 filenotfounderror:文件是存在的,权限也给了,但还一直报错
  • ¥15 安卓qpython向ksweb服务器post文件失败