[英]HTML / CSS - Frozen Table Column on the right side
我在這里找到了固定/冷凍左欄的解決方案: 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 ';}
這是你想要的? 我只為一個rwo做了。 您可以根據需要添加任意數量的行。 檢查以下HTML和樣式。
<div><table>
<tr><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td><td class="long">QWERTYUIOPASDFGHJKLZXCVBNM</td>
<td class="headcol">1</td></tr>
</table></div>
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;
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:before {content: 'Row ';}
.long { background:yellow; letter-spacing:1em; }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.