Last active
November 26, 2015 18:42
-
-
Save thinsoldier/2b0b86d20920f8d52e22 to your computer and use it in GitHub Desktop.
How to extract computed style of dom nodes as text that can be compared in a text editor.
This file contains hidden or 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
function logComputedStyles(elem,prop) { | |
var cs = window.getComputedStyle(elem,null); | |
if (prop) { | |
console.log(" "+prop+" : "+cs.getPropertyValue(prop)+"\n"); | |
return; | |
} | |
var len = cs.length; | |
var list = {}; | |
for (var i=0;i<len;i++) | |
{ | |
var style = cs[i]; | |
var value = cs.getPropertyValue(style); | |
//console.log(" "+style+" : "+value+"\n"); | |
list[style] = value; | |
} | |
return list | |
} | |
copy(JSON.stringify( logComputedStyles($0) )); | |
// Then in a text editor | |
// find: "," | |
// replace with: ",\n" | |
// Repeat for the other element | |
// Then do side by side text comparison to see what makes them look different. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment