如果对table设置table-layer:fixed样式后,发现表格中有一行合并过,其它没有合并的行的列宽会平均化,对列宽的设置会失效。
解决方法:
在tbody前面加
<col style="width: 100px;"/> <col> <col style="width: 100px;"/> <col style="width: 100px;"/> <col style="width: 100px;"/>
.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> <!--写的话就按照你写的宽度,但是如果你写的宽度占不满table它会按照你给的尺寸的比例平分至每个td--> <!--现在这么写就是四列是100px,没给数据的那一列占剩下的全部--> <col style="width: 100px;"/> <col> <col style="width: 100px;"/> <col style="width: 100px;"/> <col style="width: 100px;"/> <tbody> <tr> <td> 序号 </td> <td> 症状 </td> <td> 符合 </td> <td> 不符合 </td> <td> 不确定 </td> </tr> <?php $i = 1; ?> <?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>
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
白云城资源网 Copyright www.dyhadc.com
暂无“html解决table设置宽度无效的问题”评论...
更新日志
2024年05月13日
2024年05月13日
- 大张伟《大张伟歌曲合集》[320K/MP3][89MB]
- 郭金发.2002-台湾红歌100年·台语精选辑CD13【乡城】【WAV+CUE】
- 殷正洋.1994-等一个人【巨石】【WAV+CUE】
- 王馨平.2014-Truly【秘密花园】【WAV+CUE】
- 邓涛-精选十五首HIFI最爱天碟《试音邓涛》[WAV分轨]
- 绚香《ayakasHistory2006-2009》24bit-96kHz【Hi-Res】【flac】
- 群星-重力加速度·蓝白经华连串曲蓝与白-1991-WAV+CUE
- 孙楠《孙楠歌曲合集》[320K/MP3][252.2MB]
- 刀郎《刀郎歌曲合集》[320K/MP3][362.6MB]
- 杨培安《杨培安歌曲合集》[320K/MP3][257.1MB]
- [In-AkustikINAK7803]VA-ThePinnacleOfCheskyVoiceChesky非凡女声2017[SACD-ISO]
- 王之炅薛颖佳-中国小提琴名曲(2.8MHzDSD)DSF
- 群星-重力加速度·蓝白经华连串曲蓝与白-1991-WAV+CUE
- 群星-将爱情进行到底电视剧原声音乐中唱-1999-WAV+CUE
- [ABC唱片]徐刚-独步外滩WalkingOntheBundPerryShi(SACD).iso