【发布时间】:2013-07-02 05:56:54
【问题描述】:
好吧...我要疯了。我已经开始尝试使用 SVG。使用 SVG 并对其应用 CSS 类就像一种魅力。我只是无法弄清楚我做错了什么,但我只是无法让班级在 svg 文本元素上工作。我已经完全剥离了它,这就是我得到的:
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>Playground</title>
</head>
<body>
<style type="text/css">
.mainsvg {
height: 320px;
border: 1px solid red;
width: 400px;
}
.caption {
color: yellow;
}
</style>
<h2>SVG - Sandbox</h2>
<div>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" class="mainsvg">
<text x="65" y="40" class="caption">Fact</text>
</svg>
</div>
</body>
</html>
根据http://www.w3.org/TR/SVG/styling.html#ClassAttribute 这应该可以工作...
关于改变什么或替代方案的任何提示/提示?
【问题讨论】:
-
如果我阅读 w3 链接,您将无法设置边框。这叫中风。
-
好吧,边框效果很好。 Stroke 用于您实际“绘制”的所有内容。但我的问题是关于文本元素上的类,我在其中设置文本的颜色,就像在 w3 链接中一样。