javascript - How to get the height of svg element in Firefox.
淡淡烟草味
淡淡烟草味 2017-05-19 10:30:24
0
2
402

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>
淡淡烟草味
淡淡烟草味

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!