tnrich
tnrich

Reputation: 8580

Why can't svg scale to fit child elements?

I would an svg element which could scale to fit its children elements. Say you have:

<svg> 
  <rect width=10 height=1000/>
<svg>

It seems like there would be a way to get the svg to scale to fit the rectangle inside of it.

Unfortunately, it appears such a thing is impossible, at least according to this:

SVG Fill Width to Child Elements

Can anyone give me an explanation as to why this cannot be acheived? It seems like this would be a highly requested feature... or maybe I'm just not getting something.

Thanks!

Upvotes: 2

Views: 2253

Answers (1)

Paul LeBeau
Paul LeBeau

Reputation: 101820

A special viewBox value of "auto" has been discussed for inclusion in the specification for SVG 2, which is still under development.

If it makes the final specification, this would do what you are suggesting.

Upvotes: 1

Related Questions