惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
F
Full Disclosure
Microsoft Azure Blog
Microsoft Azure Blog
Jina AI
Jina AI
Recent Announcements
Recent Announcements
美团技术团队
L
LangChain Blog
P
Privacy & Cybersecurity Law Blog
M
MIT News - Artificial intelligence
www.infosecurity-magazine.com
www.infosecurity-magazine.com
W
WeLiveSecurity
Engineering at Meta
Engineering at Meta
S
Security @ Cisco Blogs
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Help Net Security
Help Net Security
L
LINUX DO - 最新话题
S
Secure Thoughts
O
OpenAI News
Hacker News - Newest:
Hacker News - Newest: "LLM"
A
About on SuperTechFans
NISL@THU
NISL@THU
C
Cyber Attacks, Cyber Crime and Cyber Security
Cyberwarzone
Cyberwarzone
T
Tailwind CSS Blog
T
The Blog of Author Tim Ferriss
Recent Commits to openclaw:main
Recent Commits to openclaw:main
F
Fortinet All Blogs
B
Blog
IT之家
IT之家
T
Tor Project blog
L
Lohrmann on Cybersecurity
Webroot Blog
Webroot Blog
博客园 - 叶小钗
Simon Willison's Weblog
Simon Willison's Weblog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
量子位
Security Latest
Security Latest
TaoSecurity Blog
TaoSecurity Blog
S
Schneier on Security
C
Cisco Blogs
博客园 - 三生石上(FineUI控件)
J
Java Code Geeks
Last Week in AI
Last Week in AI
The Last Watchdog
The Last Watchdog
博客园 - 聂微东
Cisco Talos Blog
Cisco Talos Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Google DeepMind News
Google DeepMind News
SecWiki News
SecWiki News

博客园 - meil

C#下取得Exif中照片拍摄日期 DotNet中人民币符号的输出 BAT实现照片文件批量改名 Wicket中JQuery事件绑定失效的解决 软件开发中的完整测试所包括的环节UT、IT、ST、UAT Eclipse中SVN插件的安装方式 从mysql中导出单个表结构和数据 代码帝:一个月10万行代码 PHP中使用mktime获取时间戳的一个黑色幽默 Android开发调试工具ADB的使用 Android系统权限配置 Android程序开发基础之——页面传值 Android程序开发基础之——页面布局 Android程序开发的环境配置 SQLServer2008 动态SQL实践 Javascript实现DIV滚动自动滚动到底部 SQL Server 日期格式转换示例大全 TinyMCE使用手册 LINQ中的OrderBy实现多字段升序、降序排序实现
ASP.net中实现双表格同步缩放不变形
meil · 2012-03-08 · via 博客园 - meil

项目中有一个表格中需要显示数据,特殊之处在于。表格的数据部需要在本页滚动,而标题头不动。

实现很简单,用两个表格控件并接在一起,一个显示数据标题,一个显示数据,数据表格嵌套在DIV中实现滚动,这样基本就可以实现需求了。

但是这个页面中的表格的列不能固定都是使用百分百来控制,这样就有一个问题及时你在设计的时候保持上下表格的对齐,但是当IE窗体别拉伸的时候上下两个表格就不能保持同步缩放,导致整个表格变形。

下图是这个显示数据的表格效果图

最终,想到的办法就是上下两个表格都放在DIV中,并且都是设置上下滚动条,但是标题部的DIV滚动条使用样式表单控制让其与页面颜色一致(都是白色)。这样无论页面如何拉伸上下两个表格始终保持缩放同步。

下面是实现的代码:(关键的地方在代码的第一行)

 1 <div style="height:13px;overFlow-y:scroll;SCROLLBAR-HIGHLIGHT-COLOR:#FFF;SCROLLBAR-DARKSHADOW-COLOR:#FFF;SCROLLBAR-ARROW-COLOR:#FFF;SCROLLBAR-TRACK-COLOR:#FFF;SCROLLBAR-FACE-COLOR:#FFF;SCROLLBAR-SHADOW-COLOR:#FFF;SCROLLBAR-3DLIGHT-COLOR:#FFF;">
2 <asp:table id="tbl_title" runat="server" width="100%" borderwidth="1px" cellspacing="0"
3 cellpadding="0">
4 <asp:TableRow verticalalign="Middle" borderwidth="1px" horizontalalign="Center" forecolor="Black" backcolor="LightCyan" font-size="Smaller" font-bold="True">
5 <asp:TableCell borderwidth="1px" width="10%" text="列1"></asp:TableCell>
6 <asp:TableCell borderwidth="1px" width="30%" text="列2"></asp:TableCell>
7 <asp:TableCell borderwidth="1px" width="10%" text="列3"></asp:TableCell>
8 <asp:TableCell borderwidth="1px" width="10%" text="列4"></asp:TableCell>
9 <asp:TableCell borderwidth="1px" width="30%" text="列5"></asp:TableCell>
10 <asp:TableCell borderwidth="1px" width="10%" text="列6"></asp:TableCell>
11 </asp:TableRow>
12 </asp:table>
13 </div>
14 <div id="divDetail" style="height:290px;overFlow-y:scroll;">
15 <asp:table id="tblResult" runat="server" width="100%" borderwidth="1px" cellspacing="0"
16 cellpadding="0">
17 </asp:table>
18 </div>

哈哈!办法很笨了,但是想要的效果出来了。欢迎大家拍砖!