table 多行 宽度不一致 您所在的位置:网站首页 html中table和html表格的关系 table 多行 宽度不一致

table 多行 宽度不一致

2023-08-16 14:05| 来源: 网络整理| 查看: 265

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 实验室设备网 版权所有