I am working with a div element that has left padding assigned as a percentage, like so:
padding-left: 1%;
However, I need to obtain the value of this padding in pixels for some calculations after the window has been resized. When using JavaScript to check element.style.paddingLeft
, it only returns the original value "1%". How can I accurately get the actual amount of padding in pixels when it's set as a percentage?
Unfortunately, I cannot make changes to the main CSS file to convert the units from % to px, so that is not an option.
Thank you for your assistance.