占位符CSS未在IE 11中应用 [英] Placeholder CSS not being applied in IE 11

查看:185
本文介绍了占位符CSS未在IE 11中应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用占位符css时遇到了一些问题。

I am getting some problem in applying placeholder css.

我正在尝试应用css(即颜色:#898F9C; )在输入框占位符上使用伪类选择器 : - ms-input-placeholder ,但它在IE中不起作用。

I am trying to apply css (i.e. color:#898F9C;) on input-box placeholder using pseudo-class selector :-ms-input-placeholder, but it's not working in IE.

演示

经过一番尝试后,我得到了解决问题的方法,但它太棒了。

After some hit and try, I get solution of my problem, but it's amazing.

如果我删除了输入框上的默认css /样式颜色,占位符css在IE中正常工作(这是Internet Explorer的惊人行为)。

If i removed the default css/style color on input-box, placeholder css working properly in IE(It's amazing behavior of Internet Explorer).

我的默认css / style:

My default css/style:

#search
{
    color:blue;
}

没有输入框默认css的工作小提琴

我的问题是,为什么它不适用于IE中的默认CSS?

My question is, why it's not working with default CSS in IE?

推荐答案

除了 Raj回答之外,当使用供应商前缀时,需要将选择器分成每个前缀的自己的规则集。

Further to what Raj answered, when using vendor prefixes the selectors need to be separated into their own rule sets for each prefix.

这样做的原因是为了使CSS语言能够推进,浏览器需要删除他们不理解的选择器或声明。这允许添加新功能,而不用担心旧浏览器会以不同的方式解释它而不仅仅是删除它。

The reason for this is that to enable the CSS language to advance, browsers need to drop selectors or declarations they do not understand. This allows new features to be be added without the worry that old browsers will interpret it in a different way other than just dropping it.

当使用逗号组合器来组合时各种伪类,你把它变成一个选择器,浏览器需要理解应用该规则集的整个事物。

When using the comma combinator to combine the various pseudo classes, you turn it into one selector, and the browser needs to understand the entire thing to apply that rule set.

相反,您应该为每个供应商前缀伪类/元素创建一个新规则集。不幸的是,重复次数很多,但这是使用实验性CSS的代价。

Instead you should make a new rule set for each vendor prefixed pseudo class/element. Unfortunately it is a lot of repetition, but that is the price for using experimental CSS.

这篇关于占位符CSS未在IE 11中应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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