th固定 td滚动的表格实现

为什么这样?
体验好
原理
通过两个表格,使其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>
th固定 td滚动的表格实现的更多相关文章
- div+css实现表头固定内容滚动表格
<div class="m-demo"> <table> <thead> <tr><th>定宽a</th>& ...
- 放弃antd table,基于React手写一个虚拟滚动的表格
缘起 标题有点夸张,并不是完全放弃antd-table,毕竟在react的生态圈里,对国人来说,比较好用的PC端组件库,也就antd了.即便经历了2018年圣诞彩蛋事件,antd的使用者也不仅不减,反 ...
- jfixed使固定行列可编辑表格
功能: 固定行列 可以在表格直接编辑 使用ajax对数据操作 使用tab键在可编辑列切换简单介绍一下jfixed 表格插件, jfixed /jfixed.rar
- css设置背景固定不滚动效果的示例
css设置背景固定不滚动效果的示例 背景固定不滚动各位看到最多的无非就是QQ空间了,我们在很多的空间都可以看到内容滚动而北京图片不滚动了,下文整理了几个关于背景固定不滚动css代码. 一.css设置背 ...
- layui静态表格固定td宽度,table固定td宽度
正在做一个项目,要求数据表的列是不固定的,有可能是有10列,有可能是20列,第一列宽度要固定,然后我怎么设置都没有用, 这个问题困扰了我三天,后来终于百度到了, 这个博客: https://www.c ...
- Table实现表头固定 内容滚动
<div style="width: 800px;"> <div class="table-head"> <table> & ...
- flex上下固定中间滚动布局
传统 pc 端中,子容器高度超出父容器高度,通常使用 overflow:auto 可出现滚动条拖动显示溢出的内容,而移动web开发中,由于浏览器厂商的系统不同.版本不同,导致有部分机型不支持对弹性滚动 ...
- table 的thead th 固定 tbody滚动例子
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- 关于boostrap的thead固定tbody滚动
原文地址:http://blog.csdn.net/bbsyi/article/details/51126041# 1 <!DOCTYPE html> 2 <html> 3 & ...
随机推荐
- MySQL存储过程、函数和游标
这里我新建了两个表,一个users和test CREATE TABLE users( username ), pwd ) ); CREATE TABLE test( id INT, username ...
- android开发,assets下面的资源文件不会变化/改动
我再调试asserts下面的资源文件,发现我改动assets下面的文件内容,在真机上测试的时候还是最原先的内容,没有变,后来,卸载,重装就ok了. 原因: assets下面的资源文件,若覆盖重装,则里 ...
- Makedown常用符号整理
整理自:http://www.jianshu.com/p/1e402922ee32 不过这里发现博客园的makedown语法支持还不完善,代码语法显示挺有问题的,比较遗憾. 标题 # 一级标题## 二 ...
- 使用GitHub建立自己的个人主页
1.建仓库 在自己的库里建一个hujun123qwe.github.io的库 即可以使用这个名字当网址访问. 2.写内容 在库里建一个首页文件 index.html 这个个人主页只支持静态的内容,像p ...
- ios7去除手势滑动返回
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { sel ...
- JAVA Hibernate工作原理及为什么要用(转)
hibernate 简介:hibernate是一个开源框架,它是对象关联关系映射的框架,它对JDBC做了轻量级的封装,而我们java程序员可以使用面向对象的思想来操纵数据库.hibernate核心接口 ...
- MySQL主从关系设置(转)
来源:LAMP兄弟连 作者:李恺 http://***/php/bencandy.php?fid=70&id=635 要做MySQL主从关系的设置,那么就得有两台MySQL主机.所以在开始之前 ...
- java poi导入EXCEL xls文件代码
/** * */ package com.bn.car.common.report.excel; import java.io.FileInputStream; import java.io.IOEx ...
- 层次数据结构字符串处理,split函数使用
String str1 = "11@22#33,44,55,#bb#cc,dd,ee,#@DDD@TTT#999,#@"; String[] CX = str1.split(&qu ...
- Interface Comparator
int compare(T o1, T o2) Compares its two arguments for order. Returns a negative integer, zero, or a ...