0

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

Is there a workaround for this?

NomNomCameron
  • 419
  • 5
  • 14

1 Answers1

1

Try using Element.getBoundingClientRect()

var elem = document.querySelector(/* selector */);
var elemPositionLeft = elem.getBoundingClientRect().left;
guest271314
  • 1
  • 15
  • 104
  • 177
  • This will only get me the offset from the edge of the screen. In the case that I'm using this (where the element goes past the edge) this is not the correct value. – NomNomCameron Jun 21 '16 at 01:51
  • @NomNomCameron _"In the case that I'm using this (where the element goes past the edge) this is not the correct value"_ Can you describe expected result?, create a jsfiddle http://jsfiddle.net to demonstrate? – guest271314 Jun 21 '16 at 01:52