table 多行 宽度不一致 | 您所在的位置:网站首页 › html中table和html表格的关系 › table 多行 宽度不一致 |
1. 给table加边框 table{ border-collapse: collapse;/*表格的边框合并为一个单一的边框*/} table, table tr th, table tr td { border:1px solid #ccc; } 还有种傻傻的方法: table{ border-top:1px solid #ccc; border-left:1px solid #ccc; } table tr td, table tr th{ border-right:1px solid #ccc; border-bottom: 1px solid #ccc; } 2.给table的th固定宽度 ① 设置table的宽度 ② table设置table-layout : fixed ; ③ 设置th宽度 3.给table加滚动条 在table外包一层div,div设置overflow属性 div{overflow-x:scroll; } 4.给td加滚动条 在td里加一层div,div宽度100%,且设置overflow属性 5.td里嵌套table,且table有滚动条 ① 最外层的table加上宽度、table-layout:fixed;word-break:break-all;(防止内层的table内容过长,将外层td撑开) ②在td和第二层table之间,加一层div;div设置overflow属性,再给内层table的th设置宽度就行 |
CopyRight 2018-2019 实验室设备网 版权所有 |