2011-09-18 74 views
0

帮助下,我有如下一点CSS代码:我寻求CSS技巧

input{ 
    background-image:url(css_img/input_bg.gif); 
    padding:6px; 
    margin:1px; 
    width:250px; 
    font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; 
    font-size:12px; 
    font-weight:bold; 
    font-variant:normal; 
    height:30px; 
    -moz-border-radius:3px 3px 3px 3px; 
    -moz-box-shadow:0 2px 3px #DDDDDD; 
    border:1px solid #aaa; 
    color:#333333; 
} 

但是这个代码改变了所有的<input type="..."/>标签的风格。我如何改变文本字段<input type="text" name="name" />的样式?我不想为他们添加类。

还有什么办法可以绕过角落只是使用简单的CSS(不使用图像),它很好地在Internet Explorer。

请帮我...

回答

4

使用的attribute selector

input[type="text"] { 
    /* styles here */ 
} 
+0

这是正确的吗?输入[type =“submit”] { \t background-image:url(css_img/ahfrwwh24u6.png); \t background-repeat:no-repeat; \t border:#CCC 0px solid; \t padding:4px; \t颜色:#FFFFFF; \t光标:指针; \t font-size:12px; \t font-family:“Trebuchet MS”,Arial,Helvetica,sans-serif; \t font-weight:bold; } –

+0

它不工作......可能是什么原因? –

+0

它应该工作。演示:http://jsfiddle.net/e4PGn/ – Sparkup

2

使用属性选择:

input[type="text"] { styles here } 
0

随着Eric和Rikudo说:

input[type="text"] 

对于即使用角落CSS3 PIE

还可以使用:具有

input[type=text] 
input[type^=te] 
input[type$=ex] 
input[type*=t] 

与属性类型元件输入包含一个值,该值等于,开头,结尾或包含一定的价值。

更多信息here

+0

我使用了两个如上所示的CSS。一个是input [type =“text”] {.. code ..},另一个是input [type =“submit”] {.. code ..}但是仍然不能在Internet Explorer上工作?为什么。我的CSS是在externel的css文件 –

+0

'input [type $ = ex]'不起作用。用'$ ='你试图搜索单词'ex'的末尾,但是在'input type ='text''里面,你应该写'$ ='xt''。 – uzay95