表格首行首列固定
表格首行首列固定
<style>/*外層div,設置寬高度*/div{overflow:auto;width:400px;height:250px;border:1px solid gray;border-bottom: 0;border-right: 0;}table {border-collapse:separate;/*設置邊框會被分開,而不是合并*/table-layout: fixed;/*列寬由表格寬度和列寬度設定。*/width: 100%;word-break:break-all;/*內容自動換行*/}th {background-color:lightblue;}td, th {border-right :1px solid gray;border-bottom :1px solid gray;width:100px;height:30px;box-sizing: border-box;text-align:center;}th:first-child {position:sticky;left:0; /* 首列最左 */z-index:1;}thead tr th {position:sticky;top:0; /* 首行最上 */}/*左上角第一個單元格,顯示優先級要最高*/thead th:first-child{z-index:2;background-color:lightblue;}</style>總結
- 上一篇: 计算机硬件技术的应用毕业论文,计算机硬件
- 下一篇: 分治法实验-寻找第k小元素