如何为特定输入类型文本添加css [英] How to add css for specific input type text

查看:104
本文介绍了如何为特定输入类型文本添加css的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试用css添加一些输入字段

When I was trying to add some input fields with css

我遇到了问题

这是我拥有的字段

<input type="text" name="firstName" />
<input type="text" name="lastName" />

且css是

input
{
   background-image:url('images/fieldBG.gif');
   background-repeat:repeat-x;
   border: 0px solid;
   height:25px;
   width:235px;
}



我想用第一个字段>

I want to make the first field (firstName) with this css

input
{
   background-image:url('images/fieldBG.gif');
   background-repeat:repeat-x;
   border: 0px solid;
   height:25px;
   width:235px;
}

,第二个(lastName)与此css

and the second one (lastName) with this css

input
{
   background-image:url('images/fieldBG2222.gif');
   background-repeat:repeat-x;
   border: 0px solid;
   height:25px;
   width:125px;
}

help: - )

推荐答案

使用ID选择器。

CSS:

input
{

background-repeat:repeat-x;
border: 0px solid;
height:25px;
width:125px;
}

#firstname
{
background-image:url('images/fieldBG.gif');
}
#lastname
{
background-image:url('images/fieldBG2222.gif');
}

HTML:

<input type="text" ID="firstname" name="firstName" />

<input type="text" ID="lastname" name="lastName" />

您的所有输入都将使用通用输入样式,而两个特殊的输入将具有样式由ID选择器指定。

All your inputs will be styled with the generic input style, and the two special ones will have the styling specified by the ID selector.

这篇关于如何为特定输入类型文本添加css的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆