Difference between two styles of elements in Google Chrome

I use the Google Chrome developer tools, and I constantly check one element against the other back and forth to find out what might cause a particular style problem.

It would be nice to compare the differences in styles between element 1 and element 2.

Can this be done with chrome at present or with some workaround? Is there a tool that can do what I'm looking for?

The current example of the difference in styles is that I have a built-in H4 next to A , where A appears above when vertically aligned. I am not looking for a solution in this matter, as I will understand.

+61
css google-chrome google-chrome-devtools google-chrome-extension styles
25 Sept. '12 at 23:19
source share
1 answer



Update: As a result of this discussion, the Diff CSS "Chrome Extension.

enter image description here




Great question and cool idea to expand!

Proof of concept

As a proof of concept, we can do a little trick here and avoid creating an extension. Chrome saves the items that you select using the check item button in variables. The last item selected at $0 , one before that at $1 , etc. Based on this, I created a small snippet that compares the last two elements tested:

 (function(a,b){ var aComputed = getComputedStyle(a); var bComputed = getComputedStyle(b); console.log('------------------------------------------'); console.log('You are comparing: '); console.log('A:', a); console.log('B:', b); console.log('------------------------------------------'); for(var aname in aComputed) { var avalue = aComputed[aname]; var bvalue = bComputed[aname]; if( aname === 'length' || aname === 'cssText' || typeof avalue === "function" ) { continue; } if( avalue !== bvalue ) { console.warn('Attribute ' + aname + ' differs: '); console.log('A:', avalue); console.log('B:', bvalue); } } console.log('------------------------------------------'); })($0,$1); 

How to use it?

Inspect the two elements you want to compare one by one, and paste the code above into the console.

Result

sample output from provided snippet

+126
Sep 26 '12 at 7:19
source share



All Articles