我试图在滚动时保持标题固定,但我无法弄清楚。
这是我的 ListView 代码:
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="FormSectionSubSectionItemRelID" OnSelectedIndexChanged="ListView1_SelectedIndexChanged">
这是我的 sites.css 表的 CSS 代码:
table {
border-collapse: collapse;
border-spacing: 0;
margin-top: 0.75em;
border: 0 none;
}
th {
font-size: 1.2em;
text-align: left;
border: none 0px;
padding-left: 0;
}
th a {
display: block;
position: relative;
}
th a:link, th a:visited, th a:active, th a:hover {
color: #333;
font-weight: 600;
text-decoration: none;
padding: 0;
}
th a:hover {
color: #000;
}
th.asc a, th.desc a {
margin-right: .75em;
}
th.asc a:after, th.desc a:after {
display: block;
position: absolute;
right: 0em;
top: 0;
font-size: 0.75em;
}
th.asc a:after {
content: '▲';
}
th.desc a:after {
content: '▼';
}
td {
padding: 0.25em 2em 0.25em 0em;
border: 0 none;
}
tr.pager td {
padding: 0 0.25em 0 0;
}
如果有一个属性我可以更改或更改我的 css 代码,那就太好了。
最佳答案
如果您也可以从服务器端获取您的代码并创建您的代码演示,这将非常有助于为您解决这个问题。
然而,只是浏览你的代码,看看你是如何询问试图在你的页面顶部固定一些东西的,我在你的 css 代码中看到一个绝对定位的元素在页面顶部我假设你希望这个元素在滚动时固定吗?
如果是这种情况,那么您需要将此代码从绝对更改为固定。
th.asc a:after, th.desc a:after {
display: block;
position: fixed; //fixed will not scroll with the page, where absolute will.
right: 0em;
top: 0;
font-size: 0.75em;
}
关于css - 如何在 ListView 中轻松创建固定标题 asp.net,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24310220/