Is there a way to obtain the dimensions and position of an element using Element.getBoundingClientRect()
, but without taking into consideration any transformations applied through the CSS property transform
? I am looking for a method that provides the rectangle values without the transformation effects.
In this scenario, the desired output should be 10 10 100 100
.
const rect = div.getBoundingClientRect()
document.write(`${rect.left} ${rect.top} ${rect.width} ${rect.height}`)
body {
margin: 10px;
}
div {
background: red;
width: 100px;
height: 100px;
transform: translate(1px, 1px) scale(0.5)
}
<div id="div"></div>