Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVG Rect Ignores Height?

Tags:

css

svg

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.

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

Working example.

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>
like image 743
BruteCode Avatar asked Jan 17 '13 15:01

BruteCode


Video Answer


2 Answers

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.

like image 135
Robert Longson Avatar answered Sep 16 '22 12:09

Robert Longson


The width of a <rect> element isn't a CSS property in SVG, it's only usable as an attribute. It's for example like the size of a <select> element in HTML. You can only set it as an attribute.

like image 30
Thomas W Avatar answered Sep 19 '22 12:09

Thomas W