Css implementation for Fixed Grid headers and fixed columns

Source: Internet
Author: User
<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>

 

<Div style = "overflow-y: scroll; height: 200px; width: 300px" id = "dvBody">

<Asp: GridView ID = "GridView1" runat = "server "......

.....

 

<HeaderStyle BackColor = "#006699" Font-Bold = "True" ForeColor = "White" CssClass = "Freezing"/>
</Asp: GridView>
</Div>

 

Usage: CSS is set to the above style, HeaderStyle plus CssClass = "Freezing, set the height width of the Div in the GridView <div style =" overflow-y: scroll; height: 200px; width: 200px ">

 

Another method of css writing

. Fixedheadercell
{
FONT-WEIGHT: bold;
FONT-SIZE: 10pt;
WIDTH: 200px;
COLOR: white;

BACKGROUND-COLOR: darkblue;
}
 
. Fixedheadertable
{
Left: 0px;
Position: relative;
Top: 0px;
Padding-right: 2px;
Padding-left: 2px;
Padding-bottom: 2px;
Padding-top: 2px;
}
 
. Gridcell
{
WIDTH: 200px;
}

 

Css for fixed columns

. FixedHeaderTr
{
Background-color: whitesmoke;
Z-index: 10;
Position: relative;
Top: expression (this. offsetParent. scrollTop );
}
It is better to use css.

 

Fixed bar, I guess it is

. Freezing
{

Position: relative;
Table-layout: fixed;
Left: expression (this. offsetParent. scrollLeft );
Z-index: 10;
}

. Freezing td {text-overflow: ellipsis; overflow: hidden; white-space: nowrap; padding: 2px ;}

 

 

Http://www.codeproject.com/KB/webforms/FreezePaneDatagrid.aspx

 

/* Div container to wrap the datagrid */
Div # div-datagrid {
Width: 420px;
Height: 200px;
Overflow: auto;
Scrollbar-base-color: # ffeaff;
}

/* Locks the left column */
Td. locked, th. locked {
Font-size: 7pt;
Text-align: left;
Background-color: inherit;
Font-weight: bold;
Position: relative;
Cursor: default;
Left: expression (document. getElementById ("div-datagrid"). scrollLeft-2);/* IE5 + only */
}

/* Locks table header */
Th {
Font-size: 7pt;
Font-weight: bold;
Text-align: center;
Background-color: navy;
Color: white;
Font-weight: bold;
Height: 15pt;
Border-right: 1px solid silver;
Position: relative;
Cursor: default;
Top: expression (document. getElementById ("div-datagrid"). scrollTop-2);/* IE5 + only */
Z-index: 10;
}

/* Keeps the header as the top most item. Important for top left item */
Th. locked {z-index: 99; text-align: center ;}

/* DataGrid Item and AlternatingItem Style */
. GridRow {font-size: 7pt; color: black; font-family: Verdana; background-color: # ffffff; height: 15px ;}
. GridAltRow {font-size: 7pt; color: black; font-family: Verdana; background-color: # eeeeee; height: 15px ;}

Http://www.codeproject.com/KB/aspnet/FreezeHeader.aspx

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.