问题
When inspecting a web site, is it possible to disable a particular .css file? I can do it in FireFox but can't find the option in Chrome.
回答1:
If you want to remove the style for the remainder of the page session, open the DOM Inspector, locate the <link>
or <style>
element which links the style sheet, and remove the element. This causes all associated styles to be removed.
If you only want to disable the style sheet temporarily, add a new attribute disabled
to the <link>
/<style>
element. Remove this attribute to enable the style sheet again.
If the site contains lots of distracting DOM elements, you can also visit the console, and something like document.styleSheets[0].disabled = true;
(where 0
is the index of the style element).
回答2:
This is based on Rob W's helpful answer
Just paste the following into your console and change the index value accordingly.
First execution will disable stylesheet and the second will enable it.
var stylesheetIndex = 0;
var action = document.styleSheets[stylesheetIndex].disabled === false ? "Disabled " : "Enabled ";
document.styleSheets[stylesheetIndex].disabled = !document.styleSheets[stylesheetIndex].disabled;
console.log( action + "stylesheet:" + document.styleSheets[stylesheetIndex].href );
回答3:
One way would be to just find the:
<link rel="stylesheet" href="yourstyle.css" />
And change it to something else...
<link rel="stylesheet" href="yourstyleXXX.css" />
Which would stop it from working...
I bet there is a way in dev tools though...
The problem is that most people are concatenating and minifying their CSS with preprocessors... so you won't be able to take this approach in these cases.
回答4:
Install the "Web developer" extension for Chrome. You will then have various options, including the "Edit CSS", where you can make changes to any CSS file on the fly (or just completely remove its' contents).
https://chrome.google.com/webstore/detail/web-developer/bfbameneiokkgbdmiekhjnmfkcnldhhm
来源:https://stackoverflow.com/questions/16864174/chrome-disable-all-styles-from-specific-css-file