为什么这样?

体验好

原理

通过两个表格,使其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">共&nbsp;{$checknum}&nbsp;晚 合计¥{$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>

最新文章

  1. CGGeometry.h 文件详解
  2. CI在ngnix的配置
  3. maven 环境搭建
  4. 大话数据结构(十)java程序——队列
  5. codeforces723 D. Lakes in Berland(并查集)
  6. LOGSTASH再入门第一发
  7. MSSQL 获取数据库字段类型
  8. 使用QueueUserWorkerItem实现的线程池封装
  9. Jquery Validate 正则表达式实用验证代码常用的
  10. Spring + Quartz配置实例
  11. Java集合(1)一 集合框架
  12. BZOJ_3038_上帝造题的七分钟2_线段树
  13. 201671010142 java内部类
  14. java模拟http请求(代理ip)
  15. python学习笔记8-邮件模块
  16. Gravitee.io Access Management docker-compose运行
  17. java 中获得 资源文件方法
  18. typedef与前向声明
  19. PAT乙级1010
  20. pthread中互斥量,锁和条件变量

热门文章

  1. Fragment inner class should be static
  2. 线性判别分析(LDA), 主成分分析(PCA)及其推导【转】
  3. Cookie 获取
  4. 1066: [SCOI2007]蜥蜴 - BZOJ
  5. IDENTITY属性使用
  6. 汇编语言中有一种移位指令叫做循环左移(ROL),现在有个简单的任务,就是用字符串模拟这个指令的运算结果。对于一个给定的字符序列S,请你把其循环左移K位后的序列输出。例如,字符序列S=”abcXYZdef”,要求输出循环左移3位后的结果,即“XYZdefabc”。是不是很简单?OK,搞定它!
  7. 【DP/二分】BZOJ 1863:[Zjoi2006]trouble 皇帝的烦恼
  8. MATLAB——PLOT绘图
  9. 用windows远程连接linux桌面(使用tightvnc或者tigervnc)
  10. 管理Java垃圾回收的五个建议