有一个快捷方式设置!重要的CSS文件中的每个属性? [英] Is there a shortcut for setting !important on every property in a CSS file?
问题描述
我有一个大的CSS文件,我想为每个CSS属性添加!important
。是否有单行快捷方式来创建整个.css文件!important
?
I have a large CSS file for which I would like to add !important
to every CSS property. Is there one-line shortcut to make a whole .css file !important
?
推荐答案
如果您的目标是通过导入另一个样式表来覆盖样式,则应使用优先顺序。
If your goal is to override styles by importing another stylesheet, you should use the order of precedence.
<head>
<title>Title</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="style-override.css" rel="stylesheet" type="text/css" />
</head>
这里 style.css
和 style-override.css
将包含您的新的自定义css。这些样式将覆盖 style.css
中的样式。这意味着你不需要使用!important
,因为样式被覆盖。
Here the style.css
is the original and style-override.css
would contain your new custom css. These styles will override the styles from style.css
. This means you won't need to use !important
because the style is overwritten.
一个CSS重置以删除所有样式并在其上构建。
Alternatively you could add in a CSS reset to remove all styles and build on-top of that.
<head>
<title>Title</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="reset.css" rel="stylesheet" type="text/css" />
<link href="style-override.css" rel="stylesheet" type="text/css" />
</head>
在 http://meyerweb.com/eric/tools/css/reset/ 并将其添加到reset.css。
Check out a CSS reset at http://meyerweb.com/eric/tools/css/reset/ and add it to reset.css.
这篇关于有一个快捷方式设置!重要的CSS文件中的每个属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!