Bootstrap中的两个并排表

oko*_*oko 18 twitter-bootstrap twitter-bootstrap-3

是否可以在Bootstrap 3中并排显示两个表?

每个尝试使每个col-md-6,虽然它缩小了宽度,但它们不会彼此相邻(而是在全宽视图中一个在另一个的顶部).

 <div class="table-responsive">
            <table class="table table-striped">
              <thead>
                <tr>
                  <th class="col-md-1">#</th>
                  <th class="col-md-2">Header</th>
                  <th class="col-md-3">Header</th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td class="col-md-1">1,001</td>
                  <td class="col-md-2">1,001</td>
                  <td class="col-md-3">1,001</td>
                </tr>
                <tr>
                  <td class="col-md-1">1,001</td>
                  <td class="col-md-2">1,001</td>
                  <td class="col-md-3">1,001</td>
                </tr>
                 <tr>
                  <td class="col-md-1">1,001</td>
                  <td class="col-md-2">1,001</td>
                  <td class="col-md-3">1,001</td>
                </tr>
              </tbody>
            </table>
          </div>
          <h2 class="sub-header">Latest Incidents</h2>
          <div class="table-responsive">
            <table class="table table-striped">
              <thead>
                <tr>
                  <th class="col-md-1">#</th>
                  <th class="col-md-2">Header</th>
                  <th class="col-md-3">Header</th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td class="col-md-1">1,001</td>
                  <td class="col-md-2">1,001</td>
                  <td class="col-md-3">1,001</td>
                </tr>
                <tr>
                  <td class="col-md-1">1,001</td>
                  <td class="col-md-2">1,001</td>
                  <td class="col-md-3">1,001</td>
                </tr>
                 <tr>
                  <td class="col-md-1">1,001</td>
                  <td class="col-md-2">1,001</td>
                  <td class="col-md-3">1,001</td>
                </tr>
              </tbody>
            </table>
Run Code Online (Sandbox Code Playgroud)

Sha*_*lor 23

您需要将每个表包装在col-6 div中,而不是将col-6应用于表本身.这是你的代码与col-xs-6缠绕:

<div class="col-xs-6">
  <h2 class="sub-header">Subtitle</h2>
  <div class="table-responsive">
    <table class="table table-striped">...
Run Code Online (Sandbox Code Playgroud)

在这里它是行动:http://www.bootply.com/lbrQZF3152


小智 18

将col-md-6类添加到每个包装div,以便具有以下结构:

<div class="table-responsive col-md-6">
    <table>...</table>
</div>
<div class="table-responsive col-md-6">
    <table>...</table>
</div>
Run Code Online (Sandbox Code Playgroud)


kar*_*gen 9

Shawn和kmo已经指出使用col-md-6类将使这项工作.我还想补充一点,如果你在里面这样做ul,li事情可能会破裂.

解决方案很简单.只需在上面添加一个div row:

<div class="row">
  <div class="table-responsive col-md-6">
      <table>...</table>
  </div>
  <div class="table-responsive col-md-6">
      <table>...</table>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)