Notice
잡담소장소
[CSS] <table>의 일부 컬럼 가로 스크롤링 기능 본문
일단 참고했던 stackoverflow.
How do I create an HTML table with a fixed/frozen left column and a scrollable body?
I need a simple solution. I know it's similar to some other questions, like: HTML table with fixed headers and a fixed column? How can I lock the first row and first column of a table when scrolli...
stackoverflow.com
내가 필요했던 건 한두컬럼이 아니었고 게다가 colspan, rowspan 모두 섞인 상태여서 마이크로 설정이 필요했다
.scroll{
overflow-x:scroll;
overflow-y:visible;
margin-left: 400px /* 스크롤영역의 왼쪽여백 설정 */
}
/* 고정시킬 컬럼의 공통 설정 */
.fixed{
position: absolute;
width:50px;
top:auto;
border-top-width: 1px;
}
/* 고정영역별로 left 설정을 위해 클래스 생성 */
.fixed-title{
min-width:130px;
left:80px;
}
.fixed-name{
left: 240px;
}
..
<div class='scroll'>
<table>
<tr>
<!-- position 설정 후 scroll영역과 1px차이가 나서 margin-top:-1px 넣어주고 width, height 설정값을 주었다 -->
<th class='fixed fixed-title'
style="height:70px; width:85px; margin-top:-1px;">
<div style='text-align:center'>...</div>
</th>
...
</tr>
<tr>
<td class='fixed fixed-title'>..</td>
...
</tr>
</table>
</div>
티스토리 코드 기능 처음 써보는데 완전 좋당!
반응형
'Study ;3' 카테고리의 다른 글
[Javascript] Array 중복값 제거 (0) | 2020.02.18 |
---|---|
[PHP] LDAP에서 받은 thumbnailphoto 속성값을 img 태그에 넣기 (0) | 2020.01.23 |
[JAVA] Collections Reverse Sort 시 컴파일에러 (0) | 2019.12.18 |
[Javascript] a href를 통해 다운로드 시 beforeunload 이벤트 이슈 (0) | 2019.09.27 |
[Angular2] Component in Another Component (0) | 2019.08.01 |
Comments