SVG Rect忽略高度? [英] SVG Rect Ignores Height?

查看:104
本文介绍了SVG Rect忽略高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个矩形的工作演示。我想将height属性移动到css ,好吧,它不工作,给我一个空白。它发生在firefox和chrome。

Here is a working demo of a rectangle. I'd like to move the height property to css and well, it doesn't work and gives me a blank. It happens in firefox and chrome.

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

Is there a different name for it? I don't understand why I can't use a css file. The fill color works.

工作示例。

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中,x,y,width和height < rect> 元素是属性,而不是 CSS属性。只有CSS属性可以使用CSS样式。

In SVG the x, y, width and height of <rect> elements are attributes rather than CSS properties. Only CSS properties can be styled using CSS.

这篇关于SVG Rect忽略高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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