网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网页制作 > CSS
网页制作:Dreamweaver教程,FrontPages教程,Javascript教程,HTML教程,CSS教程,心得技巧,DHTML教程,网页特效,Discuz!论坛
本月文章推荐
.CSS在表格边框上的美学应用.
.利用CSS层叠(cascade)处理样式冲.
.CSS学习精品网站推荐.
.CSS模块化设计—从空格谈起.
.CSS选择器的优先级.
.用css使单行超出指定宽度的内容切.
.精通 CSS 滤镜(五).
.针对浏览器隐藏CSS之九大技巧.
.网页制作中CSS样式表的十个技巧.
.你应该知道的CSS的十八个技巧.
.CSS笔记-除了a标签外的hover属性.
.常用CSS缩写语法总结及缩写的原因.
.如何高效的学习css.
.学DIV+CSS技术,如何入门?.
.CSS 针对 Safari(WebKit)的 CS.
.CSS让表格的溢出内容隐藏起来.
.JavaScript CSS Style属性对照表.
.DIV+CSS常见错误汇总.
.CSS+DIV网页特效欣赏:非常酷的角.
.实践DIV+CSS网页布局入门指南.

GridView固定表头(不用javascript只用CSS!,很好用)

发表日期:2008-8-25


代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>GridView固定表头 清清月儿http://blog.csdn.net/21aspnet </title>
        <style>
.Freezing
   {
   
   position:relative ;
   table-layout:fixed;
   top:expression(this.offsetParent.scrollTop);  
   z-index: 10;
   }
.Freezing th{text-overflow:ellipsis;overflow:hidden;white-space: nowrap;padding:2px;}
</style>
</head>
<body style="font-size=12px">
    <form id="form1" runat="server">
    <div style="overflow-y: scroll; height: 200px;width:300px" id="dvBody">
                   <asp:GridView ID="GridView1" runat="server"    AutoGenerateColumns="False" CellPadding="3" OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing"
                        OnRowUpdating="GridView1_RowUpdating" OnRowCancelingEdit="GridView1_RowCancelingEdit" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" Font-Size="12px" OnRowCreated="GridView1_RowCreated" >
                        <FooterStyle BackColor="White" ForeColor="#000066" />
                        <Columns>
                            <asp:BoundField DataField="身份证号码" HeaderText="编号" ReadOnly="True" />
                            <asp:BoundField DataField="邮政编码" HeaderText="邮政编码" SortExpression="邮政编码" />
                            <asp:BoundField DataField="家庭住址" HeaderText="家庭住址" />
                            <asp:BoundField DataField="姓名" HeaderText="姓名" />
                           
                        </Columns>
                        <RowStyle ForeColor="#000066" />
                        <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" CssClass="ms-formlabel DataGridFixedHeader"/>
                        <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" CssClass="Freezing"/>
                    </asp:GridView>
        </div>
    </form>
</body>
</html>
用法:CSS设如上的样式,HeaderStyle加CssClass="Freezing,套住GridView的Div设置高度宽度 <div style="overflow-y: scroll; height: 200px;width:200px" >

上一篇:体验css+div 之 给整个页面添加渐变背景 人气:1319
下一篇:CSS控制LI不换行 人气:1392
浏览全部CSS的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐