Bootstrap颜色不会显示在表格中

时间:2018-02-13 13:46:08

标签: html twitter-bootstrap

我有一个奇怪的问题。颜色不会在表格中显示: 我做错了什么?

"危险"据我所知,班级应该在这里工作。

<table class="table table-bordered">

<thead>
    <tr>
        <th>ID</th>
        <th>Hardware (navn)</th>
        <th>Map</th>
    </tr>
</thead>

<tbody>

<tr class="danger">
    <td class="danger col-md-1">
        33
    </td>

    <td class="danger col-md-2">
        Something
    </td>

    <td class="danger col-md-1">
        Something else
    </td>

    <td class="danger col-md-2">
        DATE
    </td>

    <td class="danger">
        Description.........
    </td>
</tr></tbody></table>

4 个答案:

答案 0 :(得分:4)

对于使用text-danger的文字着色,使用bg-danger进行背景着色。

据我所知,Bootstrap中没有danger类。

答案 1 :(得分:1)

正如引导程序color documentation所解释的那样。

  

班级:bg-danger - 将背景颜色更改为红色。

     

类:text-danger - 将字体颜色更改为红色。

<!doctype html>
<html lang="en">

<head>
  <!-- Required meta tags -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

  <!-- Bootstrap CSS -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

  <title>Hello, world!</title>
</head>

<body>
  <table class="table table-bordered">

    <thead>
      <tr>
        <th>ID</th>
        <th>Hardware (navn)</th>
        <th>Map</th>
      </tr>
    </thead>

    <tbody>

      <tr class="danger">
        <td class="bg-danger col-md-1">
          33
        </td>

        <td class="text-danger col-md-2">
          Something
        </td>

        <td class="danger col-md-1">
          Something else
        </td>

        <td class="danger col-md-2">
          DATE
        </td>

        <td class="danger">
          Description.........
        </td>
      </tr>
    </tbody>
  </table>


  <!-- Optional JavaScript -->
  <!-- jQuery first, then Popper.js, then Bootstrap JS -->
  <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>

</html>

答案 2 :(得分:0)

你使用错误的类试试这个:

<td class="bg-danger  col-md-1">
    33
</td>

答案 3 :(得分:0)

如果您使用bootstrap 4,则正确的类为table-danger,请参阅this

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<table class="table table-bordered">

<thead>
    <tr>
        <th>ID</th>
        <th>Hardware (navn)</th>
        <th>Map</th>
    </tr>
</thead>

<tbody>

<tr class="table-danger">
    <td class="col-md-1">
        33
    </td>

    <td class="col-md-2">
        Something
    </td>

    <td class="col-md-1">
        Something else
    </td>

    <td class="col-md-2">
        DATE
    </td>

    <td class="">
        Description.........
    </td>
</tr>
<tr class="">
    <td class="col-md-1">
        33
    </td>

    <td class="table-danger col-md-2">
        Something
    </td>

    <td class="col-md-1">
        Something else
    </td>

    <td class="col-md-2">
        DATE
    </td>

    <td class="table-danger">
        Description.........
    </td>
</tr>

</tbody></table>


<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>