I'm making an animation that effects a class of menu's, It slides the menu in and out the left side of the screen. But because I change the width value for another part of the app, I have to look into the css somehow,
This is what I have in CSS:
- width (600px (dependant on device with))
Using Javascript I change:
- Width (a relative amount)
- left (-width)
The left is easy, because I can just do -element.offsetWidth But the width is harder, because I don't know how much it's going to change, and I don't want to hardcode it in either.
Does anyone know a way that lets me look into the elements css, before it's changed? (as it's written in code)
What I've tried so far:
- element.offsetWidth (Didn't work because it returns the current width and not the width written in the css)
- element.style.width (Didn't work because it returns an empty string)
NOTE: There is a similar question How do I retrieve an HTML element's actual width and height?, but the answer gives the current width, and I want the width that's set by the CSS (while loading the document)
Simplified code: