2011-08-16 4 views
2

これらの色の色名の16進数またはrgb値を取得できますか?私は背景色として「窓枠」を使用するdiv要素を設定例えばCSSシステムカラーをJavascriptで16進数に変換しますか?

http://artific.com/library/css-2-system-colors.html

セイ。私は使用できますか:

https://developer.mozilla.org/en/DOM/window.getComputedStyleどういうわけか?

+1

良い質問が、[カラー名からカラーコード]の可能複製(http://stackoverflow.com/questions/3321995/color-code-from-色名) – naveen

答えて

1

getComputedStyleが動作しているようです。

http://artific.com/library/css-2-system-colors.htmlに取り組んで)Firebugの出力:

var t = document.getElementsByClassName("window")[0]; window.getComputedStyle(t).backgroundColor; 
"rgb(255, 255, 255)" 

>>> var t = document.getElementsByClassName("menu")[0]; window.getComputedStyle(t).backgroundColor; 
"rgb(240, 240, 240)" 

>>> var t = document.getElementsByClassName("info")[0]; window.getComputedStyle(t).backgroundColor; 
"rgb(225, 225, 225)" 
関連する問題