전자 상거래 사이트의 백 오피스 용 테이블을 만들었습니다. 테이블 내용 (tbody)은 고정 된 높이를 가지고 있으며 다음 그림과 같이 오른쪽에있는 스크롤 바를 통해 스크롤 할 수 있습니다. http://img690.imageshack.us/img690/6483/screenshot20110917at819.png창 크기를 조정할 때 테이블 스크롤 막대가 사라짐
문제는 브라우저 창 크기를 조정하면이 테이블 스크롤바에 문제가 있다는 것입니다. http://img26.imageshack.us/img26/4919/screenshot20110917at820.png
정상적인 동작으로 알고 있지만 내 고객은 창 크기를 조정할 때 테이블 스크롤 막대를 유지해야한다고 주장합니다. 이 동작을 구현할 수있는 방법이 있습니까? 여기
가 참조 할 수 있도록 CSS 있습니다 : (테이블 본체의 클래스가 scrollContent입니다)/* define height and width of scrollable area. Add 16px to width for scrollbar */
div.tableContainer {
clear: both;
overflow: auto;
width: 100%;
}
/* set table header to a fixed position. WinIE 6.x only */
/* In WinIE 6.x, any element with a position property set to relative and is a child of */
/* an element that has an overflow property set, the relative value translates into fixed. */
/* Ex: parent element DIV with a class of tableContainer has an overflow property set to auto */
thead.fixedHeader tr {
position: relative
}
/* set THEAD element to have block level attributes. All other non-IE browsers */
/* this enables overflow to work on TBODY element. All other non-IE, non-Mozilla browsers */
html>body thead.fixedHeader tr {
display: block;
width: 100%
}
/* define the table content to be scrollable */
/* set TBODY element to have block level attributes. All other non-IE browsers */
/* this enables overflow to work on TBODY element. All other non-IE, non-Mozilla browsers */
/* induced side effect is that child TDs no longer accept width: auto */
html>body tbody.scrollContent {
display: block;
overflow-y: auto;
overflow-x: hidden;
width: 100%;
}
CSS만으로는 그렇게 생각하지 않습니다. 당신이 할 수있는 최선의 방법은'body'에'min-width'를 설정하면, 윈도우의 수평 스크롤 바를 사용하여 오른쪽으로 스크롤하면 테이블의 수직 스크롤바가 보입니다. JavaScript/jQuery가 옵션입니까? – thirtydot
페이지의 일부 html/데모/more를 볼 수 있습니까? –
JavaScript/JQuery는 테이블 내용을 정렬하기 위해 기존 스크립트와 충돌하지 않으면 확실히 옵션입니다. 필자는 코드 정리에 끔찍한 방법을 가진 두 명의 다른 개발자가 프로젝트를 진행해야한다는 것을 인정해야합니다. 하지만 간단한 해결책이 자바 스크립트에 존재한다면, 나는 확실히 그것을 사용할 것이다. –