简体   繁体   English

div下的CSS多个类

[英]CSS multiple classes under div

.TopClass input[type=text]
{
     //Styling 
}
.TopClass textarea
{
     //Same Styling as Above
}

So, essentially I am trying to do "Select Text inputs AND textarea inputs under TopClass". 所以,基本上我试图做“在TopClass下选择文本输入和textarea输入”。

What is the best way to condense this? 凝聚这个的最好方法是什么?

Just use the comma separator: 只需使用逗号分隔符:

.TopClass input[type=text], .TopClass textarea {
  // Styling
}

Assuming you need textarea instead of text = textarea . 假设您需要textarea而不是text = textarea Try like this: 试试这样:

<textarea type="text"></textarea>

and input 和输入

.TopClass textarea, .TopClass textarea {
  // Styling
}
.TopClass input[type=text],
.TopClass input[type=textarea]
{
     //Styling 
}

And check http://lesscss.org , probably you will like what you find there. 并查看http://lesscss.org ,可能你会喜欢你在那里找到的东西。

Optimal would be to simplify it this way as both selectors will have same styling applied: 最佳方法是以这种方式简化它,因为两个选择器都将应用相同的样式:

 .TopClass input[type=text], .TopClass textarea{

    // styling here

    }

You dont need the input for textarea as it is not an input it is its own input element 你不需要textarea的输入,因为它不是输入,它是它自己的输入元素

 <textarea type="text"></textarea>

and an input 和一个输入

 <input type="text"/>

but the CSS 但CSS

 .TopClass textarea, .TopClass input[type=text]
 {
 //Same Styling as Above
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM