HTML DOM Style columnCount 속성은 요소를 나눌 열의 수를 설정하는 데 사용됩니다.
다음은 −
의 구문입니다.columnCount 속성 설정 -
object.style.columnCount = "number|auto|initial|inherit"
위의 속성은 다음과 같이 설명됩니다.
| 값 | 설명 |
|---|---|
| 번호 | 요소의 내용이 분할될 열의 수를 설정합니다. |
| 자동 | 열의 수는 다른 속성에 의해 결정됩니다. "column-width" . 이것은 기본 속성 값입니다. |
| 초기 | 이 속성을 초기 값으로 설정합니다. |
| 상속 | 상위 속성 값을 상속하려면 |
columnCount 속성에 대한 예를 살펴보겠습니다 -
예시
<!DOCTYPE html>
<html>
<head>
<style>
div {
height: 120px;
column-count: 2;
border: 2px solid black;
background-color: mediumvioletred;
}
div > div {
background-color: yellow;
}
</style>
<script>
function changeColumnCount(){
document.getElementsByTagName("div")[0].style.columnCount="4";
document.getElementById("Sample").innerHTML="The column count is now increased to 4";
}
</script>
</head>
<body>
<div id="DIV1">
<div></div>
</div>
<p>Change the above div column count property by clicking the below button</p>
<button onclick="changeColumnCount()">Change Column Count</button>
<p id="Sample"></p>
</body>
</html> 출력

'열 수 변경' 클릭 시 버튼 -
