adding css class to multiple elements

后端 未结 4 1959
遇见更好的自我
遇见更好的自我 2020-12-28 13:20

I have created a CSS class called \'button\' and applied it to all of my INPUT tags by simply using :

.button input
{
//css stuff here
}

4条回答
  •  清酒与你
    2020-12-28 13:55

    You need to qualify the a part of the selector too:

    .button input, .button a {
        //css stuff here
    }
    

    Basically, when you use the comma to create a group of selectors, each individual selector is completely independent. There is no relationship between them.

    Your original selector therefore matched "all elements of type 'input' that are descendants of an element with the class name 'button', and all elements of type 'a'".

提交回复
热议问题