Auto height for a foreignObject in SVG

svg

Solution

Since there is no real use of scaling up and down the `foreignObject` itself, then you can set both foreignObject `height` and `width` to `1`, and via CSS set `foreignObject { overflow: visible; }` to make its content visible whatever it is and do whatever you need to do it with it.

Problem

I have, in my SVG, a foreignObject which contains a p element. I want the height of this structure to be adapted to the height of my text. The p element is already adapted : I've done nothing for that. But I have troubles for the foreignObject. If I remove the field height, it doesn't work. height:auto doesn't work either.

Original source