Skip to content

Instantly share code, notes, and snippets.

@ethertank
Created March 22, 2012 22:07
Show Gist options
  • Save ethertank/2164986 to your computer and use it in GitHub Desktop.
Save ethertank/2164986 to your computer and use it in GitHub Desktop.
ショートハンドで記述されたCSSプロパティの値から個別のスタイルを抽出する関数
var getIndividualCSSPropertyValue = function(prop, propValue, IndividualProp) {
var d = document.createElement("div");
d.style[prop] = propValue;
return d.style[IndividualProp];
};
alert( getIndividualCSSPropertyValue("margin", "0 10px 20px 30px", "marginLeft") ); // 30px
alert( getIndividualCSSPropertyValue("border", "1px solid ghostwhite", "border-color") ); // rgb(248, 248, 255)​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment