【问题标题】:Position of 2nd column in row in HTML tableHTML表格中行中第二列的位置
【发布时间】:2018-10-11 18:48:16
【问题描述】:

HTML表格行中第二列的位置不在右侧。

我有一个表格,其中第一行有一个单独的列 colspan="2" 并且行的宽度设置为 100%,其他两行有两列和宽度行设置为 90%(两列之间的空白应为 10%)。

演示:

EXPECTED:

REALITY:

我试图达到我的期望:

<td style="positon: relative; right: 0; left: 5%;">

LIVE DEMO(只是因为snippet没有给出实际结果)

完整代码:

.hidden_timer {
  visibility: hidden;
}

.visible {
  visibility: visible !important
}

.question1 {
  display: flex;
  align-items: center;
  width: 90%;
  height: auto;
  min-height: 40px;
  position: relative;
  background: blue;
  color: white;
}

.question1::after {
  content: "";
  position: absolute;
  left: -20px;
  bottom: 0;
  width: 0;
  height: 0;
  border-right: 20px solid blue;
  border-top: 20px solid transparent;
  border-bottom: 20px solid transparent;
}

.question1::before {
  content: "";
  position: absolute;
  right: -20px;
  bottom: 0;
  width: 0;
  height: 0;
  border-left: 20px solid blue;
  border-top: 20px solid transparent;
  border-bottom: 20px solid transparent;
}

.table_cstm {
  border-collapse: separate;
  border-spacing: 15;
  /* Apply cell spacing */
}
<link rel="stylesheet" href="http://docstore.co.in/kbc/style/css/bootstrap.min.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="container">
  <table id="test" class="table table-responsive table_cstm">
    <tbody>
      <tr>

        <td colspan="2">
          <div class="question1" style="justify-content: center; width: 100%;">Who was First President of India?(15204)</div>
        </td>
      </tr>
      <tr>

        <td>
          <div id="A1" class="question1" onclick="onSelect(event)">A) M K Gandhi
          </div>
        </td>
        <td style="positon: relative; right: 0; left: 5%;">
          <div id="B1" class="question1" onclick="onSelect(event)">B) Jawaharlal Nehru
          </div>
        </td>
      </tr>
      <tr>

        <td>
          <div id="C1" class="question1" onclick="onSelect(event)">C) Rajendra Prasad
          </div>
        </td>
        <td style="positon: relative; right: 0; left: 5%;">
          <div id="D1" class="question1" onclick="onSelect(event)">D) Chandra Shekhar Azad
          </div>
        </td>
      </tr>
    </tbody>
  </table>

【问题讨论】:

    标签: html css twitter-bootstrap html-table


    【解决方案1】:

    右侧单元格中的 Div 与左侧对齐。

    这将使它们浮动到右侧:

    td:last-child div {
      float:right;
    }
    

    【讨论】:

    猜你喜欢
    • 2015-02-06
    • 1970-01-01
    • 1970-01-01
    • 2017-03-03
    • 2020-10-22
    • 2013-06-30
    • 2013-06-04
    • 2010-11-10
    • 1970-01-01
    相关资源
    最近更新 更多