How to style <input type=“text”> in IE6 CSS?

时光怂恿深爱的人放手 提交于 2019-11-29 16:50:42

问题


Is there any elegant way of applying a certain style to all <input type="text"> elements under IE6? I can do it with some JavaScript, but I was wondering if there was a more elegant way of doing it.

Note - I cannot apply a certain class to all textboxes by hand. And I'd like to avoid CSS expressions.


回答1:


AFAIK, IE6 does not support attribute selectors, so I think the answer is no. You'd have to use one of the following:

  1. Add a common class attribute to all <input type="text"/> elements.
  2. Use JavaScript, as you suggested.

Both of which you want to avoid. Too bad.




回答2:


If you happen to be using jQuery, try adding this to your onDOMready:

$('input[type="text"]').addClass('typeText');

Then in your CSS you could so something like:

input.typeText, input[type="text"] {
     color:#efefef;
}



回答3:


Do you also have other input elements which you wish to style differently to the "text" element? If not, just apply the style to all input elements with CSS:

input {
border: 1px #8194b2 solid;
font : normal 100% "Tahoma", sans-serif;
}



回答4:


Does putting a class attribute on you input element work for you?

input.text{

//some CSS attributes and values here....

}

  • maybe more elegant than JS


来源:https://stackoverflow.com/questions/519945/how-to-style-input-type-text-in-ie6-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!