声明CSS规则仅适用于特定类

use*_*814 3 html css

我有以下CSS我只需要申请一个特定的div(因为冲突):

有问题的div有类名datepicker-days.我是否将以下内容声明table.datepicker-days.table?但是,我如何在.table下面宣布这个类呢?

CSS

    table {
      max-width: 100%;
      border-collapse: collapse;
      border-spacing: 0;
    }
    .table {
      width: 100%;
      margin-bottom: 18px;
    }
    .table th, .table td {
      padding: 8px;
      line-height: 18px;
      text-align: left;
      border-top: 1px solid #ddd;
    }
Run Code Online (Sandbox Code Playgroud)

HTML

<div class="datepicker-days" style="display: block; ">
      <table class=" table-condensed">
         <thead>
             <tr>
                <th class="prev">
                ....
Run Code Online (Sandbox Code Playgroud)

很抱歉,如果不清楚,CSS规则来自Bootstrap.我只是使用了一些规则,因为我使用的datepicker插件取决于那些特定的规则.所以我<tables>在我的代码中有其他实例,我不希望这些规则适用.

Dai*_*Dai 5

只需使用后代选择器:

.datepicker-days table {
    /* this rule will only apply to `<table>` elements that are descendents of any element with class "datepicker-days" */
}
Run Code Online (Sandbox Code Playgroud)