我可以“堆叠” !重要;? [英] Can I "stack" !important;?

查看:60
本文介绍了我可以“堆叠” !重要;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我google了一点儿,我找不到答案。

I googled a little bit and I couldn't find the answer.

我的问题是:堆叠!重要的工作在某种程度上?或者我可以用另一种方式实现相同的功能? 我知道这不是一个好习惯

My question is: does stacking !important works in some way? Or can I achieve the same functionality in another way? I'm aware that it's not a good practice

例如,我有:

.myOuterDiv
{
   margin-left: 5px !important; 
}

.myInnerDiv
{
   margin-left: 10px !important; 
}

很明显,内部div的内容将有10px的边距,但我可以添加另一个重要的,如

It's obvious that the content of the inner div will have a margin of 10px, but can I add another important such as

.myOuterDiv
{
   margin-left: 5px !important !important; 
}



我想做到这一点,重写内部重要,

I wanna do exactly that, override the inner important so I can have a margin-left of 10. Can I do it like this or in some other way?

推荐答案

不,你不能堆栈!important ..它不会这样工作。

No, you cannot stack !important.. it doesn't work that way.

!important 可以避免多数的时间,通常有 个选择。

!important can be avoided a majority of the time, there are usually alternatives.

这篇关于我可以“堆叠” !重要;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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