如何调整html表的列宽?

时间:2017-05-18 07:06:30

标签: css html5 twitter-bootstrap

我无法解决快照中显示的以下问题。我试图减少列的宽度,但没有效果,我真的无法解决问题?

enter image description here 这是代码:

<table class="table table-bordered table-striped table-responsive" id="table1">
                 <thead>
                    <tr>
                        <th>Sl_no:</th>
                        <th>KPI</th>
                        <th style='width:10px'>Weight(RGoB)</th>
                        <th>Target Achieved(RGoB)</th>
                        <th>Points Scored(RGoB)</th>
                        <th>Weight(External)</th>
                        <th>Target Achieved(External)</th>
                        <th>Points Scored(External)</th>
                    </tr>   
                </thead>
                <tbody>
                 <?php $id=1;
                  $proposed_kpi=App\Tbl_proposed_KPI::where('activity_id',$approved_activity->activity_id)->get();
                  foreach($proposed_kpi as $kpi):
                  ?>
                  <?php 
                    $approved_kpi=App\Tbl_KPI_approved::where('kpi_id',$kpi->kpi_id)->get();
                    foreach($approved_kpi as $approved):
                 ?>

                  <tr>
                    <td>{{$id++}}</td>
                    <td>{{$approved->approved_kpi_name}}</td>
                    <td class='td1'>{{$approved->approved_RGoB}}</td>
                    <td class='td2'><input type="text" name="target[]" id="target" style='width:100px' required></td>
                    <td class='td3'><input type="text" name="rgob_score[]" id="rgob_score" style='width:100px;border:none;' placeholder="double click"></td>
                    <td class='external'>{{$approved->approved_external}}</td>
                    <td class='td5'><input type="text" name="target1[]" id="target" style='width:100px' required></td>
                    <td class='td4'><input type="text" name="external_score[]" id="external_score" style='width:100px;border:none;' placeholder="double click"></td>
                    <input type="hidden" name="hidden_id[]" value='{{$approved->kpi_approval_id}}'>
                  </tr>

                <?php endforeach ?>
              <?php endforeach ?>
              </tbody>
              </table>`enter code here`

2 个答案:

答案 0 :(得分:0)

尝试在div周围添加table并将table-responsive类放在其上,而不是放在桌子上

<div class="table-responsive">
  <table ...>
     ...
  </table>
</div>

答案 1 :(得分:0)

将宽度设置为100%,并且表格样式必须固定。

您可以执行以下操作:

<table style="width: 100%; display: table; table-layout: fixed;" class="table table-striped table-bordered text-center table-hover table-responsive">