我的html页面中有两个表单。这两个表单都包含input type="text"属性。
如何为两种输入类型的文本提供不同的css?
如果我应用这个:
input[type=text] {
   //style
}它将改变两个表单元素的样式。
发布于 2017-03-24 00:21:02
您可以为每个输入提供其自己的Id或类选择器,并分别设置Id的样式。
<input id='input1'> </input>
<input id='input2'> </input>
<style> 
#input1 {
-- insert styles here for input 1
}
#input2 {
-- insert styles here for input 2
}
</style>您还可以通过创建内联样式(快速和脏)来实现所需的结果。
<input style="style1:theStyle;"> </input>
<input style="style2:theStyle;"> </input>以后请分享一个代码片段,并且更具描述性。
发布于 2017-03-24 00:23:10
对于这一点,我认为你可以在这个inputtype=text标签周围有任何容器。因此,您可以使用该容器作为引用,并指向这两个输入标记。
.form-container input[type=text]:nth-child(1){
border:2px dashed #000;
}
.form-container input[type=text]:nth-child(2){
border:2px dotted #000;
}<div class="form-container">
  <input type="text" >
  <input type="text">
</div>
或者你可以给输入标签加上一个'id‘。
#form-one{border:1px dashed #000;}
#form-two{border:1px dotted #000;}<div class="form-container">
<input type="text" id="form-one" >
<input type="text" id="form-two">
</div>
https://stackoverflow.com/questions/42981476
复制相似问题