How to apply different CSS styles to 2 elements with the same class name?

前端 未结 5 1064
暖寄归人
暖寄归人 2020-12-10 04:34

I created a website that has different navigation menus. In 2 menus, I use the same HTML class element.

I have a .css file that styles that class element in 1 menu.

5条回答
  •  不思量自难忘°
    2020-12-10 05:29

    You can also do something like this:

    Some code
    Some different code

    And the CSS for the first .classname would be something like that:

    .classname:not(.second) {}
    

    For the second element it goes easily:

    .classname.second {}
    

提交回复
热议问题