JSFiddle - React, Tailwind, and code Playground
by Shashank D
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<script src="https://code.jquery.com/jquery-3.2.1.js"></script>
</head>
<body>
<div>
<svg id="foo"></svg>
</div>
</body>
</html>
CSS
div {
width: 200px;
height: 200px;
background: #00f;
}
svg {
width: 100%;
height: 100%;
background: #f00;
}
JavaScript
$(function () {
var svg = document.getElementById('foo');
console.log( svg.clientWidth, svg.clientHeight);
console.log( svg.parentNode.clientWidth, svg.parentNode.clientHeight);
console.log( svg.getBoundingClientRect().width, svg.getBoundingClientRect().height);
console.log( svg.width.baseVal.value, svg.height.baseVal.value);
});