Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 使用Fontello SVG作为背景图像_Css_Svg_Webfonts_Fontello - Fatal编程技术网

Css 使用Fontello SVG作为背景图像

Css 使用Fontello SVG作为背景图像,css,svg,webfonts,fontello,Css,Svg,Webfonts,Fontello,我正在使用从生成的字体图标(web字体)。下载的软件包包括SVG文件 例如。我生成的fontello软件包只包含一个图标(mail-1) 情况如下: <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg xmlns="http://www.

我正在使用从生成的字体图标(web字体)。下载的软件包包括SVG文件

例如。我生成的fontello软件包只包含一个图标(mail-1) 情况如下:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg">
   <metadata>Copyright (C) 2015 by original authors @ fontello.com</metadata>
   <defs>
      <font id="fontello" horiz-adv-x="1000">
         <font-face font-family="fontello" font-weight="400" font-stretch="normal" units-per-em="1000" ascent="850" descent="-150" />
         <missing-glyph horiz-adv-x="1000" />
         <glyph glyph-name="mail-1" unicode="&#xe802;" d="m929 11v428q-18-20-39-37-149-114-238-188-28-24-46-38t-48-27-57-13h-2q-26 0-57 13t-48 27-46 38q-88 74-238 188-21 17-39 37v-428q0-8 6-13t12-5h822q7 0 12 5t6 13z m0 586v14t-1 7-1 7-3 5-5 4-8 2h-822q-7 0-12-6t-6-12q0-94 82-159 108-85 224-177 4-2 20-16t25-21 25-18 28-15 24-5h2q11 0 24 5t28 15 25 18 25 21 20 16q116 92 224 177 30 24 56 65t26 73z m71 21v-607q0-37-26-63t-63-27h-822q-36 0-63 27t-26 63v607q0 37 26 63t63 26h822q37 0 63-26t26-63z" horiz-adv-x="1000" />
      </font>
   </defs>
</svg>
…我是在…上读到的

但我不知道如何从我的svg(Fontello)代码生成以下数据:image/svg+xml代码。当然,我粘贴了这个SVG代码,因为它在背景:url('data:image/SVG+xml;…中,但它不起作用。。。 救命啊

  • 只需将图像转换为
  • 删除所有glyph属性,如unicode
  • 添加“变换”和“缩放”以实际显示适当大小的元素
  • 您可以在path元素上使用图标宽度的大小
    transform='scale()'

    我选择使用200px作为它的大小(大约)

    然后您可以在url()中使用它

    .svgback{
    背景图像:url(“数据:image/svg+xml;utf8,”);
    宽度:200px;
    高度:200px;
    }

    我通过以下步骤创建一个svg文件,其中包含一个来自glyph的路径

    • 首先,转到
      config.json
      并找到该字符
    应该是这样的:

    {
          "uid": "91d1768d00bc3e6ee51c2fcea9810679",
          "css": "my-address",
          "code": 57514,
          "src": "custom_icons",
          "selected": true,
          "svg": {
            "path": "M994.5 17.7C988.8 11.8 980 10.1 972.5 13.6L11.3 454.7C3.6 458.3-0.9 466.5 0.2 474.9S7.8 490 16.2 491.4L447.3 563.7 496.6 971.1C497.7 979.6 504.1 986.4 512.6 987.9 513.7 988.1 514.8 988.2 515.8 988.2 523.1 988.2 529.9 984.1 533.2 977.4L998 39.8C1001.6 32.4 1000.2 23.6 994.5 17.7Z",
            "width": 1000
          },
          "search": [
            "myaddress-icon"
          ]
        }
    
    • 复制其
      路径
      值,并将其插入如下svg路径(将svg的宽度和高度值设置为配置中的宽度值):
    
    
    并将其另存为.svg文件

    最后,您可以使用图像编辑器(我使用inkscape)打开它,并将矢量图像调整到viewbox

    你可以把它作为背景

    {
          "uid": "91d1768d00bc3e6ee51c2fcea9810679",
          "css": "my-address",
          "code": 57514,
          "src": "custom_icons",
          "selected": true,
          "svg": {
            "path": "M994.5 17.7C988.8 11.8 980 10.1 972.5 13.6L11.3 454.7C3.6 458.3-0.9 466.5 0.2 474.9S7.8 490 16.2 491.4L447.3 563.7 496.6 971.1C497.7 979.6 504.1 986.4 512.6 987.9 513.7 988.1 514.8 988.2 515.8 988.2 523.1 988.2 529.9 984.1 533.2 977.4L998 39.8C1001.6 32.4 1000.2 23.6 994.5 17.7Z",
            "width": 1000
          },
          "search": [
            "myaddress-icon"
          ]
        }
    
    <svg width="1000" height="1000" xmlns="http://www.w3.org/2000/svg">
      <path d="M994.5 17.7C988.8 11.8 980 10.1 972.5 13.6L11.3 454.7C3.6 458.3-0.9 466.5 0.2 474.9S7.8 490 16.2 491.4L447.3 563.7 496.6 971.1C497.7 979.6 504.1 986.4 512.6 987.9 513.7 988.1 514.8 988.2 515.8 988.2 523.1 988.2 529.9 984.1 533.2 977.4L998 39.8C1001.6 32.4 1000.2 23.6 994.5 17.7Z"/>
    </svg>