简体   繁体   English

Bootstrap 4表对齐问题

[英]Bootstrap 4 table align issue

I have a problem about aligning some items. 我在对齐某些项目时遇到问题。

In the following Fiddle I have 2 options Option1 and Option2 . 在下面的小提琴中,我有2个选项Option1Option2 I would like to align the toggle switches with the ones in the first two rows. 我想将拨动开关与前两行中的开关对齐。

Basically I want the toggle switches to be in the second column of the table and the text that are below them in the first column. 基本上,我希望切换开关位于表的第二列中,而其下方的文本位于第一列中。

Any ideas how can I solve it ? 有什么想法可以解决吗?

Thank you 谢谢

You're using bootstrap, so I would ditch the tables. 您正在使用引导程序,所以我会抛弃桌子。 But if you must use the tables, simply make the table rows and columns uniform. 但是,如果必须使用表格,只需使表格的行和列统一即可。

Here's an updated fiddle with the correct nesting 这是带有正确嵌套的更新小提琴

<div class="container">
  <table class="table table-bordered">
      <thead style="" class="">
          <tr class="d-flex">
              <th class="col-6">My </th>
              <th class="col-6"></th>
          </tr>
      </thead>
      <tbody>
          <tr class="d-flex">
              <td class="text-sm-left col-sm-11">some text
              </td>
              <td class="text-sm-right col-sm-1">
                <div class="switch">
                  <input id="cmn-toggle-5" class="cmn-toggle cmn-toggle-round-flat" type="checkbox">
                  <label for="cmn-toggle-5"></label>
                </div>
              </td>
          </tr>
          <tr class="d-flex">
              <td class="text-sm-left col-sm-11">some text
              </td>
              <td class="text-sm-right col-sm-1">
                <div class="switch">
                  <input id="cmn-toggle-5" class="cmn-toggle cmn-toggle-round-flat" type="checkbox">
                  <label for="cmn-toggle-5"></label>
                </div>
              </td>
          </tr>
          <tr class="d-flex">
              <td class="col-sm-12">testtexttex :</td>
          </tr>

          <tr class="d-flex">
              <td class="col-sm-11">Option1
                 <button type="button" class='btn btn-secondary '>
                     <span class="fa fa-envelope"></span>
                 </button></td>
              <td class="col-sm-1">
                <div class="switch">
                  <input id="cmn-toggle-5" class="cmn-toggle cmn-toggle-round-flat" type="checkbox">
                  <label for="cmn-toggle-5"></label>
                </div>
              </td>
          </tr>
          <tr class="d-flex">
              <td class="col-sm-11">Option2
                 <button type="button" class='btn btn-secondary '>
                     <span class="fa fa-envelope"></span>
                 </button></td>
              <td class="col-sm-1">
                <div class="switch">
                  <input id="cmn-toggle-5" class="cmn-toggle cmn-toggle-round-flat" type="checkbox">
                  <label for="cmn-toggle-5"></label>
                </div>
              </td>
          </tr>
      </tbody>
  </table>
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM