CSS 为什么 input[type=text] 在 IE 中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3656237/
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
Why input[type=text] is not working in IE
提问by niao
I have some style like this:
我有这样的风格:
<style type="text/css">
input[type=text]{
width:300px;
}
</style>
the above code works in chrome and firefox. Why not in IE? I am using this code in Reporting services at the end of Reports.aspx file.
上面的代码适用于 chrome 和 firefox。为什么不在 IE 中?我在 Reports.aspx 文件末尾的 Reporting Services 中使用此代码。
回答by RPM1984
Which version of IE?
哪个版本的IE?
IE6 and lower do not support attribute selectors.
IE6 及更低版本不支持属性选择器。
Just use a class, keep it simple:
只需使用一个类,保持简单:
input.text
{
width:300px;
}
<input type="text" class="text" />
回答by Damien_The_Unbeliever
It works fine in IE8, assuming the page is loading in IE7 or IE8 standards mode (not quirks)
它在 IE8 中工作正常,假设页面在 IE7 或 IE8 标准模式下加载(不是怪癖)
Edit
编辑
You've said you're using IE8. In which case, use the developer tools (F12), locate your text box, and check what styles are being applied.
你说过你正在使用 IE8。在这种情况下,请使用开发人员工具 (F12),找到您的文本框,然后检查正在应用的样式。
Edit 2
编辑 2
Don't know which version of reporting services you're using. Just went to a 2000 instance, and the report manager is serving up pages that render in quirks mode, so good luck getting much, if any, styling to work.
不知道您使用的是哪个版本的报告服务。刚刚去了一个 2000 实例,报告管理器正在提供以 quirks 模式呈现的页面,所以祝你好运,如果有的话,样式可以工作。
Edit 3
编辑 3
You may be able to force IE to render in IE8 mode by adding a meta tagto the head within the aspx pages. E.g. :
您可以通过在 aspx 页面的头部添加元标记来强制 IE 以 IE8 模式呈现。例如:
<head>
<meta http-equiv="X-UA-Compatible" content="IE=100" >
<!-- Rest of <head> -->
回答by Venemo
Use the IE7-JS script. (It was originally created to add some features of IE7 to IE6, thus the name.)
使用 IE7-JS 脚本。(它最初是为了将 IE7 的一些功能添加到 IE6 中而创建的,因此得名。)
It can add this feature to both IE6 and IE7. (Note that IE9.js is newest and it also fixes a bunch of other thingsin how IE interprets CSS.)
它可以将此功能添加到 IE6 和 IE7。(请注意,IE9.js 是最新的,它还修复了IE 解释 CSS 的许多其他问题。)
回答by Damo
Double check that you don't have a space between the "input" and the "[". This burned me lately. Worked in FF/Chrome but not IE.
仔细检查“输入”和“[”之间是否没有空格。这让我最近很生气。在 FF/Chrome 但不是 IE 中工作。