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
在:before选择器中通过CSS缩放SVG图标_Css_Svg - Fatal编程技术网

在:before选择器中通过CSS缩放SVG图标

在:before选择器中通过CSS缩放SVG图标,css,svg,Css,Svg,如何将SVG图标作为CSS:before选择器的一部分进行缩放 例如: a[href$=".xml"]:before { content: url(http://public.xxx.com/html9.svg); width: 20px; height: 20px; } <a href="foo.xml">foo.xml</a> a[href$=”.xml“]:之前{ 内容:网址(http://public.xxx.com/html9.svg

如何将SVG图标作为CSS:before选择器的一部分进行缩放

例如:

a[href$=".xml"]:before {
    content: url(http://public.xxx.com/html9.svg);
    width: 20px;
    height: 20px;
}

<a href="foo.xml">foo.xml</a>
a[href$=”.xml“]:之前{
内容:网址(http://public.xxx.com/html9.svg);
宽度:20px;
高度:20px;
}
像这样:

以及CSS的相关更改:

a[href$=".xml"]:before {
    content: '';
    background-image: url(http://public.xxx.com/html9.svg);
    background-size: contain;
    width: 20px;
    height: 20px;
    display: inline-block;
}

内容如何:''我清楚地询问了如何使用CSS,而不是为了弄乱我的干净标记。这就是CSS。但不是加载url,而是加载图像:(请仔细阅读我的问题。我想在这里使用CSS有一个很好的理由:不要弄乱现有的标记-尤其是当标记不在我的控制之下时。很难理解?javascript不是一个选项?因为正如你提到的:你不能用CSS包含标记。内容不在DOM中,所以你不能通过CSS。