有一个快捷方式设置!重要的CSS文件中的每个属性? [英] Is there a shortcut for setting !important on every property in a CSS file?

查看:199
本文介绍了有一个快捷方式设置!重要的CSS文件中的每个属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆