为什么CSS [margin-right]没有在html中应用?

时间:2018-12-09 09:17:04

标签: html css bootstrap-4

代码:

table {
  border-radius: 3px;
  margin-top: 5px;
  margin-left: 5px;
  margin-right: 5px;
}
<div class="table-responsive-md">
  <table class="table table-striped table-bordered table-hover table-sm text-light">

    <caption>The todo-List</caption>

    <thead class="thead-dark">
      <tr>
        <th>#</th>
        <th>Date of Diclaration</th>
        <th>Date of Finish</th>
        <th>Target To Be Nailed</th>
      </tr>
    </thead>

    <tbody>
      <tr class="bg-primary">
        <td>1</td>
        <td>13 nov 1998</td>
        <td>13 nov 2019</td>
        <td>Meet her</td>
      </tr>
      <tr class="bg-dark ">
        <td>1</td>
        <td>13 nov 1998</td>
        <td>13 nov 2019</td>
        <td>Meet her</td>
      </tr>
    </tbody>
  </table>
</div>

我知道我要问你的事很愚蠢,但请帮我好吧!! 我无法在表格的右边距上正确地设置边距,而我试图将其更改为右边距:50px或5%; 但是什么都没有解决。.所以请提出一些更改以使其正确..谢谢

1 个答案:

答案 0 :(得分:0)

.table-responsive-md{
  padding-left:5px;
  padding-right:5px;
}
<div class="table-responsive-md">
  <table class="table table-striped table-bordered table-hover table-sm text-light">

    <caption>The todo-List</caption>

    <thead class="thead-dark">
      <tr>
        <th>#</th>
        <th>Date of Diclaration</th>
        <th>Date of Finish</th>
        <th>Target To Be Nailed</th>
      </tr>
    </thead>

    <tbody>
      <tr class="bg-primary">
        <td>1</td>
        <td>13 nov 1998</td>
        <td>13 nov 2019</td>
        <td>Meet her</td>
      </tr>
      <tr class="bg-dark ">
        <td>1</td>
        <td>13 nov 1998</td>
        <td>13 nov 2019</td>
        <td>Meet her</td>
      </tr>
    </tbody>
  </table>
</div>

由于表格是全宽的,因此右边距不能正常工作。如果您在父标记上使用向左填充和向右填充,您将做您想做的事情。