How many times have we struggled to find one specific problem messing adult your CSS layout? From blank shutting tags to improperly nested siblings, CSS issues are a dime a dozen. And with this CSS blueprint debugger, a routine usually got a lot easier.
This one line of formula will traverse a DOM and outline any element with a opposite color. This approach we can better visualize how your CSS is operative (or not working) and quickly mark problem areas.
GitHub allows developers to save small pieces of code called Gists. These are all open source and giveaway to save for your possess use. That’s because this CSS debugger is so useful. It combines a modern bravery of Chrome DevTools with a simplicity of browser bookmarklets.
To use this code, we should initial copy whichever chronicle we like a best from a Gist page. Then, we paste that code into your Terminal window and run it. You should finish adult with a outcome like this:
Now, it is probable to save this formula as a bookmarklet in your browser toolbar. But if you’re a Chrome user we can save this JS formula as a formula snippet that is most easier to run.
This formula dash can be recalled over and over during a click of a button. You can parse any page, full of these colorful CSS outlines, for DOM elements of relatives and children alike.
However, we shouldn’t feel singular usually to Chrome. This dash works for all vital browsers, including Firefox, Safari, Opera, and Internet Explorer.
And for anyone extraordinary to learn how this works, we can check out a annotated version with comments for any line of code.
This Gist is full of related user comments and updates from other developers assisting to make it smaller and some-more efficient. But in a stream state, this is one of a simplest ways to debug any DOM with a singular line of code.
How to Refactor CSS – A Guide
Editor’s note: This essay is partial of the Code Optimization series, where we take a demeanour during how…Read more