Created
June 25, 2014 06:14
-
-
Save breezhang/db8059454d871f28aada to your computer and use it in GitHub Desktop.
chrome color log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//defile out style debug css code | |
//eg; | |
.xxy { | |
color:green; | |
font-size:16px; | |
font-weight:bold; | |
} | |
// js code read and format css | |
//help function | |
function getStyle(className) { | |
var l = document.styleSheets.length; | |
for(var i=0;i<l;i++){ | |
var classes = document.styleSheets[i].rules || document.styleSheets[i].cssRules; | |
for(var x=0;x<classes.length;x++) { | |
if(classes[x].selectorText==className) { | |
return ((classes[x].cssText) ? classes[x].cssText : classes[x].style.cssText).replace(/({)|(})|className/g,""); | |
} | |
} | |
} | |
} | |
//===============just call ============================ | |
console.log("%c this is demo ",getStyle('.xxy')); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment