th固定 td滚动的表格实现
2024-10-18 21:27:57
为什么这样?
体验好
原理
通过两个表格,使其th td 对应,产生一种错觉。
代码
1.html
<div class="content">
<div class="table-head">
<table>
<colgroup>
<col style="width: 25%;" /><col />
<col style="width: 25%;" /><col />
<col style="width: 25%;" /><col />
<col style="width: 25%;" /><col />
</colgroup>
<thead>
<tr>
<th>日期</th>
<th >单价</th>
<th >数量</th>
<th >小计</th>
</tr>
</thead>
</table>
</div>
<div class="table-body">
<table>
<colgroup>
<col style="width: 25%;" /><col />
<col style="width: 25%;" /><col />
<col style="width: 25%;" /><col />
<col style="width: 25%;" /><col />
</colgroup>
<tbody>
{loop $data $k $v}
<tr>
<td scope="row">{$v['date']}</td>
<td>{if isset($v['discount'])}¥{$v['price']}<span style="text-decoration:line-through;color:#999999;">¥{$v['oprice']}</span>{else}¥{$v['price']}{/if}</td>
<td>{$v['roomnum']}</td>
<td>¥{$v['subtotal']}</td>
</tr>
{/loop}
</tbody>
</table>
</div>
<div class="total">共 {$checknum} 晚 合计¥{$allprice}</div>
</div>
2.css
<style>
.table-head{padding-right:17px;background-color:#999;color:#000;}
.table-body{width:100%; height:390px;overflow-y:scroll;}
.table-head table,.table-body table{width:100%;}
.table-head tr,.table-body tr{line-height: 35px;}
.table-head th,.table-body td{text-align: center;}
.table-body table tr:nth-child(2n+1){background-color:#f2f2f2;}
.total {
float:right;
padding-right: 20px;
margin-top:5px;
}
</style>
核心
<colgroup>
<col style="width: 25%;" /><col />
<col style="width: 25%;" /><col />
<col style="width: 25%;" /><col />
<col style="width: 25%;" /><col />
</colgroup>
最新文章
- CGGeometry.h 文件详解
- CI在ngnix的配置
- maven 环境搭建
- 大话数据结构(十)java程序——队列
- codeforces723 D. Lakes in Berland(并查集)
- LOGSTASH再入门第一发
- MSSQL 获取数据库字段类型
- 使用QueueUserWorkerItem实现的线程池封装
- Jquery Validate 正则表达式实用验证代码常用的
- Spring + Quartz配置实例
- Java集合(1)一 集合框架
- BZOJ_3038_上帝造题的七分钟2_线段树
- 201671010142 java内部类
- java模拟http请求(代理ip)
- python学习笔记8-邮件模块
- Gravitee.io Access Management docker-compose运行
- java 中获得 资源文件方法
- typedef与前向声明
- PAT乙级1010
- pthread中互斥量,锁和条件变量
热门文章
- Fragment inner class should be static
- 线性判别分析(LDA), 主成分分析(PCA)及其推导【转】
- Cookie 获取
- 1066: [SCOI2007]蜥蜴 - BZOJ
- IDENTITY属性使用
- 汇编语言中有一种移位指令叫做循环左移(ROL),现在有个简单的任务,就是用字符串模拟这个指令的运算结果。对于一个给定的字符序列S,请你把其循环左移K位后的序列输出。例如,字符序列S=”abcXYZdef”,要求输出循环左移3位后的结果,即“XYZdefabc”。是不是很简单?OK,搞定它!
- 【DP/二分】BZOJ 1863:[Zjoi2006]trouble 皇帝的烦恼
- MATLAB——PLOT绘图
- 用windows远程连接linux桌面(使用tightvnc或者tigervnc)
- 管理Java垃圾回收的五个建议