In essence, I am trying to use the getComputedStyle to get a property value without having access to the element (directly). Please read the description below for further details.
This is difficult to explain so please tell me if you don't understand.
Here is my CSS code:
.yScrollButton{
background-color:#aaa;
width:100%;
position:absolute;
top:0;
min-height:30px;
}
.xScrollButton{
background-color:#aaa;
height:100%;
position:absolute;
top:0;
min-width:30px;
}
The elements linked to the these classes are generated with JavaScript. How do I get the min-width:30px;
or min-width:30px;
property values without using an element to find them. Usually for this situation, you use getComputedStyle
https://stackoverflow.com/a/18676007/3011082 but in this situation I can't get the the source element for the computed style (see example below)!
var yourDiv = document.getElementById("some-id");
getComputedStyle(yourDiv).getPropertyValue("margin-top")
Again, this is confusing so please tell me if you don't understand :) The solution must be in only JavaScript, no JQuery.
Now that I think about it, a better way to understand this question is to use
var yourDiv = document.getElementById("some-id"); getComputedStyle(yourDiv).getPropertyValue("margin-top")
without the
yourDiv
element.
Thank you.