Css 如何使用相同的类将输入元素和选择元素作为目标

Css 如何使用相同的类将输入元素和选择元素作为目标,css,grouping,Css,Grouping,我如何编写它以两个元素为目标而不编写两次 .field_with_errors input{ color: red; background: #CEF6EC; border: 1px solid red; } .field_with_errors select{ color: red; background: #CEF6EC; border: 1px solid red; } 这行不通 .field_with_errors select in

我如何编写它以两个元素为目标而不编写两次

.field_with_errors input{
    color: red;
    background: #CEF6EC;
    border: 1px solid red;
}


.field_with_errors select{
    color: red;
    background: #CEF6EC;
    border: 1px solid red;
}
这行不通

.field_with_errors select input{
    color: red;
    background: #CEF6EC;
    border: 1px solid red;
}
多个css选择器必须用逗号分隔。您必须为每个选择器重复整个选择器,如上所述

此外,在每个逗号后加一个换行符是一种常见做法,以使css更具可读性-它不会影响结果,因此以下含义相同:

.field_with_errors select,
.field_with_errors input {

多个css选择器必须用逗号分隔。您必须为每个选择器重复整个选择器,如上所述

此外,在每个逗号后加一个换行符是一种常见做法,以使css更具可读性-它不会影响结果,因此以下含义相同:

.field_with_errors select,
.field_with_errors input {

.field_with_errors select, .field_with_errors input {
.field_with_errors input,.field_with_errors select{
    color: red;
    background: #CEF6EC;
    border: 1px solid red;
}