NomNomCameron NomNomCameron - 1 year ago 69
CSS Question

Can't get computed style of position that uses calc() in Safari

With an element that uses

for positioning (e.g.
div { left: calc(100% - 50px); }
) Safari returns nil for window.getComputedStyle(elem).left

Is there a workaround for this?

Answer Source

Try using Element.getBoundingClientRect()

var elem = document.querySelector(/* selector */);
var elemPositionLeft = elem.getBoundingClientRect().left;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download