I have an input field of type text
<input type="text">
Currently, I am utilizing JavaScript's ClientRect
to retrieve caret details. The ClientRect
object structure is as follows:
[object ClientRect]
{
[functions]: ,
__proto__: { },
bottom: 540.7999877929687,
constructor: { },
height: 24,
left: 1034.5399169921875,
right: 1034.5399169921875,
top: 516.7999877929687,
width: 0
}
This data is generated with every user input.
left: 1034.5399169921875,
left: 1065.5399169921875,
left: 1078.5399169921875,
My goal is to convert these numbers into CSS units such as px/%/rem/vh
, enabling me to apply dynamic styles. How can this conversion be achieved?