html - 第一个和第二个 Bootstrap 表列之间的大空白

标签 html css twitter-bootstrap

如何删除名称列和第一个包含 24 的日期列之间的大空白?

它看起来是由 Bootstrap CSS 引起的,但我不确定为什么。

当日历中有更多可用日期时,根据我的基础模型问题就会消失,但我正在努力找出原因。

#container-body {
  padding-bottom: 1rem;
  padding-top: 1rem;
}

#locala-oc {
  height: 30px;
  padding-right: 1rem;
}

table.dt-table {
  border-spacing: 0;
}

div.dataTables_wrapper div.dataTables_paginate ul.pagination {
  justify-content: center;
  margin: 0;
}

nav {
  border-bottom: 1px solid #792273;
}

.form-text-bottom {
  display: block;
  margin-bottom: 0.5rem;
}

thead.remove-header-top > tr > th {
  border-top: 0;
  padding-top: 0;
}

tr.table-striped-odd {
  background-color: rgba(0, 0, 0, 0.05);
}

.validation-summary-errors ul {
  list-style: none;
}

.stock-card {
  height: 220px;
}

.stock-card-header {
  height: 80px;
  vertical-align: middle;
}

#calendar th,
#calendar td {
  white-space: nowrap;
}

#calendar th.name,
#calendar td.name {
  background: white;
  position: absolute;
  margin-left: -200px;
  width: 200px;
}

.calendar-wrapper {
  overflow-x: scroll;
  width: 100%;
}

#calendar {
  table-layout: fixed;
  margin-left: 200px;
}

#calendar col.day,
#calendar th.day,
#calendar td.day {
  width: 40px;
  text-align: center;
}

#calendar > thead > tr > th.weekend,
#calendar > tbody > tr > td.weekend {
  background: lightgray;
}

#calendar > tbody > tr > td.user-rt {
  background-color: #792273;
}

#calendar > tbody > tr > td.user-al {
  background-color: darkgray;
}

#calendar > tbody > tr > td.user-rt.user-al {
  background: -webkit-gradient(linear, left top, right bottom, color-stop(50%, red), color-stop(50%, green));
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<div class="calendar-wrapper">
  <table id="calendar" class="table table-bordered">
    <colgroup>
      <col class="name">
        <col class="day" data-date="20171124">
          <col class="day weekend" data-date="20171125">
            <col class="day weekend" data-date="20171126">
              <col class="day" data-date="20171127">
                <col class="day" data-date="20171128">
                  <col class="day" data-date="20171129">
                    <col class="day" data-date="20171130">
    </colgroup>
    <thead>
      <tr>
        <th class="name">&nbsp;</th>
        <th class="text-center" colspan="7">November 2017</th>
      </tr>
      <tr>
        <th class="name">Name</th>
        <th class="day" data-date="20171124">24</th>
        <th class="day weekend" data-date="20171125">25</th>
        <th class="day weekend" data-date="20171126">26</th>
        <th class="day" data-date="20171127">27</th>
        <th class="day" data-date="20171128">28</th>
        <th class="day" data-date="20171129">29</th>
        <th class="day" data-date="20171130">30</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="name">User A</td>
        <td class="day user-rt" data-date="20171124" data-userid="1873">
          &nbsp;
        </td>
        <td class="day weekend user-rt" data-date="20171125" data-userid="1873">
          &nbsp;
        </td>
        <td class="day weekend user-rt" data-date="20171126" data-userid="1873">
          &nbsp;
        </td>
        <td class="day user-rt" data-date="20171127" data-userid="1873">
          &nbsp;
        </td>
        <td class="day user-rt" data-date="20171128" data-userid="1873">
          &nbsp;
        </td>
        <td class="day user-rt" data-date="20171129" data-userid="1873">
          &nbsp;
        </td>
        <td class="day user-rt" data-date="20171130" data-userid="1873">
          &nbsp;
        </td>
      </tr>
    </tbody>
  </table>
</div>

最佳答案

您的表格 的宽度为 100%。将其更改为 width: auto

#container-body {
  padding-bottom: 1rem;
  padding-top: 1rem;
}

#locala-oc {
  height: 30px;
  padding-right: 1rem;
}

table.dt-table {
  border-spacing: 0;
}

div.dataTables_wrapper div.dataTables_paginate ul.pagination {
  justify-content: center;
  margin: 0;
}

nav {
  border-bottom: 1px solid #792273;
}

.form-text-bottom {
  display: block;
  margin-bottom: 0.5rem;
}

thead.remove-header-top > tr > th {
  border-top: 0;
  padding-top: 0;
}

tr.table-striped-odd {
  background-color: rgba(0, 0, 0, 0.05);
}

.validation-summary-errors ul {
  list-style: none;
}

.stock-card {
  height: 220px;
}

.stock-card-header {
  height: 80px;
  vertical-align: middle;
}

#calendar th,
#calendar td {
  white-space: nowrap;
}

#calendar th.name,
#calendar td.name {
  background: white;
  position: absolute;
  margin-left: -200px;
  width: 200px;
}

.calendar-wrapper {
  overflow-x: scroll;
  width: 100%;
}

#calendar {
  table-layout: fixed;
  margin-left: 200px;
}

#calendar col.day,
#calendar th.day,
#calendar td.day {
  width: 40px;
  text-align: center;
}

#calendar > thead > tr > th.weekend,
#calendar > tbody > tr > td.weekend {
  background: lightgray;
}

#calendar > tbody > tr > td.user-rt {
  background-color: #792273;
}

#calendar > tbody > tr > td.user-al {
  background-color: darkgray;
}

#calendar > tbody > tr > td.user-rt.user-al {
  background: -webkit-gradient(linear, left top, right bottom, color-stop(50%, red), color-stop(50%, green));
}

.table{
  width: auto !important;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<div class="calendar-wrapper">
  <table id="calendar" class="table table-bordered">
    <colgroup>
      <col class="name">
        <col class="day" data-date="20171124">
          <col class="day weekend" data-date="20171125">
            <col class="day weekend" data-date="20171126">
              <col class="day" data-date="20171127">
                <col class="day" data-date="20171128">
                  <col class="day" data-date="20171129">
                    <col class="day" data-date="20171130">
    </colgroup>
    <thead>
      <tr>
        <th class="name">&nbsp;</th>
        <th class="text-center" colspan="7">November 2017</th>
      </tr>
      <tr>
        <th class="name">Name</th>
        <th class="day" data-date="20171124">24</th>
        <th class="day weekend" data-date="20171125">25</th>
        <th class="day weekend" data-date="20171126">26</th>
        <th class="day" data-date="20171127">27</th>
        <th class="day" data-date="20171128">28</th>
        <th class="day" data-date="20171129">29</th>
        <th class="day" data-date="20171130">30</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="name">User A</td>
        <td class="day user-rt" data-date="20171124" data-userid="1873">
          &nbsp;
        </td>
        <td class="day weekend user-rt" data-date="20171125" data-userid="1873">
          &nbsp;
        </td>
        <td class="day weekend user-rt" data-date="20171126" data-userid="1873">
          &nbsp;
        </td>
        <td class="day user-rt" data-date="20171127" data-userid="1873">
          &nbsp;
        </td>
        <td class="day user-rt" data-date="20171128" data-userid="1873">
          &nbsp;
        </td>
        <td class="day user-rt" data-date="20171129" data-userid="1873">
          &nbsp;
        </td>
        <td class="day user-rt" data-date="20171130" data-userid="1873">
          &nbsp;
        </td>
      </tr>
    </tbody>
  </table>
</div>

关于html - 第一个和第二个 Bootstrap 表列之间的大空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47475922/

相关文章:

javascript - epub3使用html + JS

css - Rails 4 图像在生产中更大

jquery - 我无法将我的 jquery 代码作为工具运行

css - SASS 变量导入

javascript - 在 Bootstrap 容器的开头启动光滑的 slider 并全宽滚动

html - 在不增加尺寸的情况下向 Bootstrap 网格添加边距

html - 如何在 div 中水平居中对齐图像?

javascript - jQuery - 在 if 语句参数中使用 css

html - 如何使描述列表中的不同定义彼此相邻 float ?

.NET 和 Twitter Bootstrap 按钮