Assume that viewport width is 1024px.
<div>hoge</div>
div {
width: auto;
}
var element = document.querySelector('div');
var spedifiedStyle = getSpecifiedStyle(element);
var computedStyle = getComputedStyle(element);
console.log(spedifiedStyle.getPropertyValue('width'));//auto
console.log(computedStyle.getPropertyValue('width'));//1024px
bower install get-specified-style.js
or
yarn add get-specified-style.js
<script src="/path/to/get-specified-style.js">
Almost the same as getComputedStyle
let style = getSpecifiedStyle(element[, pseudoElt]);
style.getPropertyValue(propertyName);//any value
style.getPropertyPriority(propertyName);//'' or 'important'
style.getSpecificity(propertyName);// 0~10000
- specificity - Calculate the specificity of a CSS selector