Apply css to all element except one who has specific parent

后端 未结 2 797
心在旅途
心在旅途 2021-01-23 20:40

I want to apply CSS to all pages except sidebars. Let me show you an example

.page #buddypress ul.group li
相关标签:
2条回答
  • 2021-01-23 21:11

    You can override all css for that element by using its ID (css id overrides css class). A possibility would be:

    #id{all:unset}
    

    However, this has limited browser support and your specified element should have an ID.
    See also: https://stackoverflow.com/a/36892781/9204431

    0 讨论(0)
  • 2021-01-23 21:18

    Try this code

    div:not(.sidebar) ul.group li {
      border: 1px solid red;
    }
    // Here i have used div, but you can use whatever tag you have used for sidebar
    <body class="page">
    
      <div class="sidebar">
        <ul class="group">
          <li>1</li>
          <li>2</li>
          <li>3</li>
        </ul>
      </div>
      
      <div class="page-section">
        <ul class="group">
          <li>1</li>
          <li>2</li>
          <li>3</li>
        </ul>
      </div>
      
    </body>

    0 讨论(0)
提交回复
热议问题