HTML DOM 스타일 tableLayout 속성은 HTML 문서에서 테이블 셀, 행 및 열이 배치되는 방식을 반환하고 수정합니다.
구문
다음은 구문입니다 -
1. tableLayout 반환
object.tableLayout
2. tableLayout 수정
object.tableLayout = “value”
여기서 값은 -
일 수 있습니다.| 값 | 설명 |
|---|---|
| 초기 | 이 속성 값을 기본값으로 설정합니다. |
| 상속 | 상위 요소에서 이 속성 값을 상속합니다. |
| 고정 | 컬럼과 테이블의 너비를 기준으로 컬럼 너비를 설정합니다. |
| 자동 | 테이블에서 깨지지 않는 가장 넓은 콘텐츠의 너비를 기준으로 열 너비를 설정합니다. |
HTML DOM 스타일 tableLayout 속성의 예를 살펴보겠습니다 -
예시
<!DOCTYPE html>
<html>
<style>
body {
color: #000;
background: lightblue;
height: 100vh;
text-align: center;
}
table {
margin: 2rem auto;
width: 400px;
}
.btn {
background: #db133a;
border: none;
height: 2rem;
border-radius: 2px;
width: 40%;
display: block;
color: #fff;
outline: none;
cursor: pointer;
margin: 1rem auto;
}
</style>
<body>
<h1>DOM Style tableLayout Property Demo</h1>
<table border="2">
<caption>Student Entry</caption>
<tr>
<th>Name</th>
<th>Roll No.</th>
</tr>
<tr>
<td>John</td>
<td>031717</td>
</tr>
<tr>
<td>Elon</td>
<td>041717</td>
</tr>
</table>
<button onclick="show()" class="btn">Set tableLayout</button>
<script>
function show() {
document.querySelector('table').style.tableLayout = "fixed";
}
</script>
</body>
</html> 출력

"tableLayout 설정을 클릭합니다. 고정 으로 tableLayout을 설정하는 ” 버튼 가치 -
