CSS 如何禁用 IE10 插入文本框的清除按钮?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13481577/
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 20:50:10  来源:igfitidea点击:

How can I disable the clear button that IE10 inserts into textboxes?

cssformsinternet-explorer-10

提问by Josh Schultz

How can I disable the new functionality in Internet Explorer 10 that shows a little 'x' in a textbox when it's focused and I have content in it?

如何禁用 Internet Explorer 10 中的新功能,该功能在文本框中显示一个小“x”,当它获得焦点并且我有内容时?

IE10 Clear Button

IE10 清除按钮

回答by Josh Schultz

input[type=text]::-ms-clear {
    display: none;
}

回答by Sutthoff

In IE 10+, text inputs (input[type=text]) show a (x) button on the right-side on the field once you start typing, it's used to clear/remove the entered text value.

IE 10+ 中,一旦您开始输入,文本输入 (input[type=text]) 会在字段右侧显示一个 (x) 按钮,用于清除/删除输入的文本值。

In Chrome, search inputs (input[type=search]) show a similar button.

Chrome 中,搜索输入 (input[type=search]) 显示一个类似的按钮。

If you prefer to remove either of them for IE10+ and/or Chrome. You can add the style below to hide this button from the input.

如果您希望为 IE10+ 和/或 Chrome 删除它们中的任何一个。您可以添加以下样式以在输入中隐藏此按钮。

See it in action...http://codepen.io/sutthoff/pen/jqqzJg

看到它在行动... http://codepen.io/sutthoff/pen/jqqzJg

/* IE10+ */
::-ms-clear {
  display: none;
}

/* Chrome */
::-webkit-search-decoration,
::-webkit-search-cancel-button,
::-webkit-search-results-button,
::-webkit-search-results-decoration { 
  display: none; 
}

回答by Amit Mhaske

This is how I did it

这就是我做到的

input[type=text]::-ms-clear
{
    display: none;
}

回答by stacksonstacksonstacks

input::-ms-clear{
   display:none;
}

This did the trick for me.

这对我有用。

回答by Tom Wilson

Note that the style and CSS solutions don't work when a page runs in compatibility view. I'm assuming that this is because the clear button was introduced after IE7, and so the IE7 renderer used in compatibility view doesn't see ::-ms-clear as a valid style heading.

请注意,当页面在兼容性视图中运行时,样式和 CSS 解决方案不起作用。我假设这是因为清除按钮是在 IE7 之后引入的,因此兼容性视图中使用的 IE7 渲染器不会将 ::-ms-clear 视为有效的样式标题。