css - SVG Rect 忽略高度?

标签 css svg

这是一个working demo的一个矩形。我想 move the height property to css好吧,它不起作用,让我一片空白。它发生在 firefox 和 chrome 中。

它有不同的名字吗?我不明白为什么我不能使用 css 文件。填充颜​​色有效。

工作示例。

CSS:

rect {
    fill:rgb(0, 0, 255);
    /*doesnt work height:100;*/
}

html:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
    <rect width="100" height="100" style="stroke-width:1;stroke:rgb(0,0,0)"/>
</svg>

最佳答案

在 SVG 中,<rect> 的 x、y、宽度和高度元素是 attributes而不是 CSS properties .只有 CSS 属性可以使用 CSS 设置样式。

关于css - SVG Rect 忽略高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14383014/

相关文章:

javascript - 仅使用 javascript 和 CSS 改变元素外观

jquery - 完全阻止 CSS 加载

javascript - SVG <g> 标签获取其 &lt;title&gt; 内容 JS/jQuery

html - 有没有办法使用 CSS 在 SVG 中填充图像?

css - Bootstrap 面板标题中的垂直居中带有超赞字体 5 SVG 图标的跨度

html - 网格元素高度不匹配响应方形 child

css - Angular 2 Material - 如何居中进度微调器

javascript - 根据屏幕大小和父 div 位置定位子 div

javascript - 使用javascript重叠两个svgs,并保存文件

javascript - 将鼠标悬停在 SVG 路径上时,如何使 div 出现?