我想请问一下为什么控制input不能用class类和id选择器?

事情是这样的,当我用input这个标签是可以控制他的样式:

input {
   border:1px solid #ccc;
   height:30px;
   width:500px;
   line-height:150px;
   font-size:15px;
}
当我设置成有class类或者还id选择器的时候为什么不行呀、?
input .txt {
   border:1px solid #ccc;
   height:30px;
   width:500px;
   line-height:150px;
   font-size:15px;
}
阅读 7.4k
3 个回答

input 后面不要加空格啊亲!

哥们,你的样式写错了

input .txt {
    border:1px solid #ccc;
    height:30px;
    width:500px;
    line-height:150px;
    font-size:15px;
}

input.txt 中间没有空格

input .txt{}

的意思是选择的,input标签下面的class=“txt”的元素。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进