如何让SVG图像从HTML文档继承颜色? [英] How do I have an SVG image inherit colors from the HTML document?

查看:1623
本文介绍了如何让SVG图像从HTML文档继承颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆SVG图片,我想嵌入到一个HTML页面,这是用CSS样式。

I have a bunch of SVG images that I want to embed in an HTML page, which is styled with CSS.

我想要能够有元素

我尝试设置 style =stroke:none; fill:inherit但是这不起作用。

I tried setting style="stroke: none; fill: inherit" but this doesn't work.

推荐答案

html使用颜色,而SVG使用填充和笔触。您可以通过使用值currentColor(例如颜色)来获取填充或描边以使用颜色CSS属性的值。 fill =currentColor

html uses color whereas SVG uses fill and stroke. You can get fill or stroke to use the value of the color CSS property by using the value currentColor e.g. fill="currentColor"

这篇关于如何让SVG图像从HTML文档继承颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆