禁用输入类型的 CSS 选择器 =“提交”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3759692/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 22:48:39  来源:igfitidea点击:

CSS selector for disabled input type="submit"

csscss-selectorssubmit-button

提问by Francisc

Is there a CSS selector for disabled input type="submit"or "button"?

是否有禁用input type="submit"或禁用的 CSS 选择器"button"

Should I just use input[type="submit"][disabled]?

我应该使用input[type="submit"][disabled]吗?

Does that work in IE6?

这在 IE6 中有效吗?

回答by jensgram

Does that work in IE6?

这在 IE6 中有效吗?

No, IE6 does not support attribute selectorsat all, cf. CSS Compatibility and Internet Explorer.

不,IE6 根本不支持属性选择器,参见。CSS 兼容性和 Internet Explorer

You might find How to workaround: IE6 does not support CSS “attribute” selectorsworth the read.

您可能会发现如何解决:IE6 不支持值得一读的CSS“属性”选择器



EDIT
Ifyou are to ignore IE6, you could do (CSS2.1):

编辑
如果你要忽略 IE6,你可以这样做(CSS2.1):

input[type=submit][disabled=disabled],
button[disabled=disabled] {
    ...
}

CSS3 (IE9+):

CSS3 (IE9+):

input[type=submit]:disabled,
button:disabled {
    ...
}

You cansubstitute [disabled=disabled](attribute value) with [disabled](attribute presence).

可以[disabled=disabled](属性值)替换为[disabled](属性存在)。

回答by Tim

As said by jensgram, IE6 does not support attribute selector. You could add a class="disabled" to select the disabled inputs so that this can work in IE6.

正如 jensgram 所说,IE6 不支持属性选择器。您可以添加一个 class="disabled" 来选择禁用的输入,以便它可以在 IE6 中工作。

回答by Meloman

I used @jensgram solution to hide a div that contains a disabled input. So I hide the entire parent of the input.

我使用@jensgram 解决方案来隐藏包含禁用输入的 div。所以我隐藏了输入的整个父级。

Here is the code :

这是代码:

div:has(>input[disabled=disabled]) {
    display: none;
}

Maybe it could help some of you.

也许它可以帮助你们中的一些人。