加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

HTML / CSS – 右侧冻结表列

发布时间:2020-12-14 18:57:21 所属栏目:资源 来源:网络整理
导读:我在这里找到了固定/冻结左列的解决方案: http://jsfiddle.net/emn13/YMvk9/ body { font:16px Calibri;} table { border-collapse:separate; border-top: 3px solid grey; } td { margin:0; border:3px solid grey; border-top-width:0px; white-space:now
我在这里找到了固定/冻结左列的解决方案: http://jsfiddle.net/emn13/YMvk9/
body { font:16px Calibri;}
    table { border-collapse:separate; border-top: 3px solid grey; }
    td {
        margin:0;
        border:3px solid grey; 
        border-top-width:0px; 
        white-space:nowrap;
    }
    div { 
        width: 600px; 
        overflow-x:scroll;  
        margin-left:5em; 
        overflow-y:visible;
        padding-bottom:1px;
    }
    .headcol {
        position:absolute; 
        width:5em; 
        left:0;
        top:auto;
        border-right: 0px none black; 
        border-top-width:3px; /*only relevant for first row*/
        margin-top:-3px; /*compensate for top border*/
    }
    .headcol:before {content: 'Row ';}
    .long { background:yellow; letter-spacing:1em; }?

但是,是否也可以获得没有Javascript或其他覆盖表的正确的固定/冻结列?

解决方法

改变下面的CSS
div { 
            width: auto; 
            overflow-x:scroll;  
            margin-right:5em; 
            overflow-y:visible;
            padding-bottom:1px; 
        }
        .headcol {
            position:absolute; 
            width:5em; 
            right:0;
            top:auto;
            border-right: 0px none black; 
            border-top-width:3px; /*only relevant for first row*/
            margin-top:-3px; /*compensate for top border*/
        }
        .headcol:after{content: 'Row ';}

DEMO

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读