The clientHeight and offsetHeight of the svg element are 0 and undefined in Firefox, but are normal in Chrome. How to get the height of svg?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<svg id="svg" viewBox="0,0,50,50" version="1.1" xmlns="http://www.w3.org/2000/svg">
<rect x="0.5" y="0.5" rx="3" ry="3" width="49" height="49" fill="transparent" stroke="black" stroke-width="1"/>
<text x="25" y="30" text-anchor="middle" font-size="14px" font-family="Yahei" fill="red">Abc</text>
</svg>
<script>
let a=document.getElementById('svg').clientHeight;
console.log(a);
</script>
</body>
</html>
Can be solved with getBoundingClientRect().height.
I haven’t encountered it specifically, but I can give you an idea. The prompts of Firefox are still user-friendly. Go directly to the console to see how the svg height is defined. If Firefox displays 0 and undefined, please post an error on the console. If I can give you some ideas, please adopt them. Thank you