CSS

::-ms-clear

非标准

这个功能是非标准的,不在标准轨道上。不要在面向Web的生产站点上使用它:它不适用于每个用户。实现之间也可能存在大的不兼容性,并且行为在未来可能会改变。

::-ms-clearCSS 伪元素表示在文本的边缘处的按钮(“清除按钮”)<input>它清除掉的当前值<input>元件。此按钮和伪元素是非标准的,仅在Internet Explorer 10和11以及Edge 12+中受支持,因此供应商前缀(-ms对于Microsoft)。清除按钮仅显示在聚焦的非空文本<input>元素上。

语法

selector::-ms-clear

HTML

<form> <label for="firstname">First name:</label> <input type="text" id="firstname" name="firstname" placeholder="First name"> <br> <label for="lastname">Last name:</label> <input type="text" id="lastname" name="lastname" placeholder="Second name"> </form>

CSS

input, label { display: block; } input[type=text]::-ms-clear { color: red;/* This sets the cross color as red. */ /* The cross can be hidden by setting the display attribute as "none" */ }

结果

对于那些无法访问IE10/11的用户,下面的屏幕截图显示了该功能的样子:

规范

不是任何规范的一部分。微软有关于MSDN的说明。它列出了可以在这个伪元素上设置的各种属性。

此功能仅在IE10-11中可用,并已在MicrosoftEdge中删除.

浏览器兼容性

FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic supportNo supportNo support10.0 1 Edge 12+No supportNo support

FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic supportNo supportNo support?No supportNo support