在IE中禁用文本框中更改字体颜色 [英] Changing font colour in Textboxes in IE which are disabled

查看:120
本文介绍了在IE中禁用文本框中更改字体颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,您可以更改文本框中的文本颜色,这是在Firefox中禁用的应用一个简单的类,但没有办法在IE 6/7。任何人都有一个优雅的解决方案来实现这一点。

I noticed that you can change the colour of text in textboxes which are disabled in Firefox applying a simple class but could not get a way to do it in IE 6/7. Does anyone out there have a elegant solution to achieve this.

推荐答案


我注意到,在Firefox中禁用的文本框中的文本颜色

I noticed that you can change the colour of text in textboxes which are disabled in Firefox

我认为问题是要说的是:

I think what the question is trying to say is that this:

<textarea disabled="disabled" style="color: red;">Hello</textarea>

在IE中输入灰色文本,而在Fox中输出为红色。 FWIW,Opera也给出了灰色,而WebKit浏览器给出了红色。

Results in grey text in IE, vs. red in Fox. FWIW, Opera also gives grey, whilst the WebKit browsers give red.

这是一个纯CSS问题,要根据操作系统的组件集和根据CSS规则多少。这一直是一个很好的跨浏览器的区别。脚本是不相关的,虽然SO想使用jQuery是每个问题的答案。

This is a pure CSS issue to do with how much form fields are rendered according to the OS's widget set and how much according to the CSS rules. This has always been an area of great cross-browser difference. Scripting is not relevant, much though SO would like "use jQuery" to be the answer to every question.

通常的解决方法是使用'readonly'而不是' ',然后使用样式(例如基于off'class =disabled')重现你想要的阴影禁用效果。 readonly控件不会变成已禁用操作系统级别的窗口小部件,为您提供更多的自由风格。

The usual workaround is to use ‘readonly’ instead of ‘disabled’, then use styling (eg. based off ‘class="disabled"’) to reproduce whatever shaded disabled effect you want. ‘readonly’ controls are not turned into OS-level-disabled widgets, giving you more latitude to style them.

这篇关于在IE中禁用文本框中更改字体颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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