【发布时间】:2020-02-20 00:35:17
【问题描述】:
我有 3 个文件:
index.html
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
<i class="logo myRed" aria-hidden="true"></i>
</body>
</html>
style.css
.logo:before {
content: url("logo.svg");
}
.myRed {
color: #ff2000;
}
logo.svg
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="300" height="100">
<rect id="logo" width="300" height="100" />
</svg>
如何设置 CSS content 属性中指出的 SVG 样式? (例如颜色,字体大小,...) - 就像在 FontAwesome 中一样。
【问题讨论】:
-
如果你不知道,只有 inline sag 可以用 css 设置样式。请记住这一点。
-
@AnuragDaolagajao 这不是真的,您可以使用 CSS 为任何 SVG 设置样式,它根本不适用跨文档。
-
您需要将 CSS 放入 SVG 文件中。
-
此问题未正确关闭。它问了一个我通过搜索找到的有用问题,它回答了我的问题。这就是正确问题的定义。
-
这就是“社区审核”的问题:人们只想结束问题,因为这让他们觉得自己在参与其中。
标签: html css svg font-awesome