代码之家  ›  专栏  ›  技术社区  ›  user982124

Bootstrap-为一个页面自定义表行突出显示类

  •  0
  • user982124  · 技术社区  · 6 年前

    我有一个引导表,允许用户选择添加 class="success" 到选定行。我使用上下文类的默认值:

    https://getbootstrap.com/docs/3.3/css/#tables-contextual-classes

    但客户希望,就这一页而言,它的成功是一个更明亮、更突出的绿色。

    下面是该表的一个示例:

    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
    <table class="table table-condensed table-striped table-bordered">
      <thead>
        <th scope="col">Serial #</th>
        <th scope="col">Product Code</th>
        <th scope="col">ID</th>
        <th scope="col">Description</th>
        <th class="text-center" scope="col">Select</th>
      </thead>
      <tbody>
        <tr class="success" id="PZs456">
          <td>ZK2342MFM</td>
          <td>JMPG</td>
          <td>98651217</td>
          <td>Keyboard - Bluetooth</td>
          <td class="text-center">
            <button type="button" class="btn btn-success btn-sm">Select</button> 
          </td>
        </tr>
      </tbody>
    </table>

    什么是最好的方法来改变'成功'的颜色,使它是一个更亮的绿色,只为这个网页,而不改变引导CSS本身?

    1 回复  |  直到 6 年前
        1
  •  2
  •   Learner    6 年前

    .new-green {
      background: #00ff00 !important;
    }
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
    <table class="table table-condensed table-striped table-bordered">
      <thead>
        <th scope="col">Serial #</th>
        <th scope="col">Product Code</th>
        <th scope="col">ID</th>
        <th scope="col">Description</th>
        <th class="text-center" scope="col">Select</th>
      </thead>
      <tbody>
    
        <tr class="success" id="PZs456">
          <td>ZK2342MFM</td>
          <td>JMPG</td>
          <td>98651217</td>
          <td>Keyboard - Bluetooth</td>
    
          <td class="text-center"><button type="button" class="btn btn-success btn-sm new-green">Select</button></td>
    
    
    
        </tr>
    
    
      </tbody>
    </table>

    我不知道这是不是一个最好的方法,但因为有很多!bootstrap中的重要事情为什么不把自己的作为新的类使用呢?