Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get cascaded style value or determine whether the actual value was computed?

I need to get a cascaded style value of an element (not the computed one), or to determine whether the actual value was computed or not.

For example, if I have an element with css rule width: 100%, I want to get the value 100% and not the actual pixels value, or just to know that the actual value was computed.

I know that I can get it using elem.currentStyle, and I also found a way in Chrome to find it using document.defaultView.getMatchedCSSRules().

Does anyone know a way to get it in other browsers?

like image 579
Andy Avatar asked Jun 17 '11 23:06

Andy


1 Answers

What about calculating the value yourself? Query the calculated width of the wanted element and the calculated width af the parent element and then do some math to get the percentage-value? percentageValue = 100% * widthOfWanted / widthOfContainer

like image 167
Niedermann IT-Dienstleistungen Avatar answered Oct 07 '22 16:10

Niedermann IT-Dienstleistungen