
地 址:北京市门头沟区66号
电 话:18022031060
邮 箱:95770807@qq.com
这篇文章主要介绍了(le)html解决table设置宽度无效的解决问题,文中通过示例代码介绍的置宽非常详细,对大家的度无学习或者工作具有(you)一定的参考学习价值,需要的问题朋友们下面随着小编来一起学习(xi)学习吧
如果对(dui)table设置table-layer:fixed样式后,发(fa)现表格中有一行合并过,解决(jue)其它没有合并的置宽行的列宽会平均化,对列宽的度无设置会失效。

解决方法:

<col style='width: 100px;'/>
<col>
<col style="width: 100px;"/>
<col style="width: 100px;"/>
<col style='width: 100px;'/>

在tbody前面加
.detail {
padding-bottom: 50px;
margin-top: 80px;
}
.detail_table {
table-layout:fixed;/*列宽由表格宽度和列宽度设定。问题*/
margin: auto;/*table居中*/
text-align: center;
border: 1px solid #804040;
border-collapse: collapse;
}
.detail_table th {
padding: 26px;;
}
.detail_table td {
border: 1px solid #804040;
padding-top: 16px;
padding-bottom: 16px;
}
.special {
text-align: left;
padding-left: 20px;
}
<div class='detail'>
<table class='detail_table'>
<thead>
<th colspan="5">选择的解决选项明细</th>
</thead>
<!--写的话就按照你写的宽度,但(dan)是置宽如果你写的宽度占不满table它会按照你给的(de)尺寸的比例平分(fen)至每个td-->
<!--现在这么(me)写就是四(si)列是100px,没给数据的那一列占剩下的全(quan)部-->
<col style='width: 100px;'/>
<col>
<col style='width: 100px;'/>
<col style='width: 100px;'/>
<col style="width: 100px;"/>
<tr>
<td>
序号
</td>
<td>
症状
</td>
<td>
符合
</td>
<td>
不(bu)符合
</td>
<td>
不确定
</td>
</tr>
<?php foreach ($test as $item): ?>
<!--拿到选择项-->
<?php $temp = $this->session->userdata('b' . $i) ?>
<tr>
<td>
<?php echo $i; ?>
</td>
<td>
<?php echo $item; ?>
</td>
<td>
<?php if ($temp == 1): ?>√<?php endif ?>
</td>
<td>
<?php if ($temp == 2): ?>√<?php endif ?>
</td>
<td>
<?php if ($temp == 3): ?>√<?php endif ?>
</td>
</tr>
<?php $i++; ?>
<?php endforeach; ?>
</tbody>
</table>
</div>
来源:脚本之家(jia)
问题链接:https://www.jb51.net/web/738041.html
问题