모바일 장치 만 타겟팅하는 경우이 방법이 유용 할 수 있습니다. 테이블의 첫 번째 열을 복제하고 position:absolute
을 적용하여 나머지 테이블을 스크롤 할 때 "앞에"나타납니다.
$(function(){
var $table = $('.table');
//Make a clone of our table
var $fixedColumn = $table.clone().insertBefore($table).addClass('fixed-column');
//Remove everything except for first column
$fixedColumn.find('th:not(:first-child),td:not(:first-child)').remove();
//Match the height of the rows to that of the original table's
$fixedColumn.find('tr').each(function (i, elem) {
$(this).height($table.find('tr:eq(' + i + ')').height());
});
});
여기에 CSS
.table-responsive>.fixed-column {
position: absolute;
display: inline-block;
width: auto;
border-right: 1px solid #ddd;
background-color: #fff; /* bootstrap v3 fix for fixed column background color*/
}
@media(min-width:768px) {
.table-responsive>.fixed-column {
display: none;
}
}
가에 대한 working demo있어
jQuery를 :
은이를 위해 당신은 몇 가지 기본적인 jQuery 코드 및 사용자 정의 CSS 클래스를 필요할 것 이 접근법
각도에서이를 수행 할 방법을 찾고 있다면 http://stackoverflow.com/a/33728417/111438 – niaher