คุณสมบัติคอลัมน์ HTML DOM ใช้สำหรับจัดการคุณสมบัติ columnWidth และ columnCount
ต่อไปนี้เป็นไวยากรณ์สำหรับ −
การตั้งค่าคุณสมบัติของคอลัมน์ -
object.style.columns = "auto|column-width column-count|initial|inherit"
ค่าคุณสมบัติข้างต้นมีคำอธิบายดังนี้ −
| ค่า | คำอธิบาย |
|---|---|
| อัตโนมัติ | ตั้งค่าความกว้างคอลัมน์และจำนวนคอลัมน์เป็นอัตโนมัติและเป็นค่าเริ่มต้น |
| คอลัมน์ความกว้าง | กำหนดความกว้างของคอลัมน์ |
| columnCount | การระบุหมายเลขคอลัมน์ |
| ค่าเริ่มต้น | การตั้งค่าคุณสมบัตินี้เป็นค่าเริ่มต้น |
| สืบทอด | การสืบทอดค่าคุณสมบัติหลัก |
มาดูตัวอย่างคุณสมบัติของคอลัมน์กัน −
ตัวอย่าง
<!DOCTYPE html>
<html>
<head>
<style>
#DIV1{
columns: 5rem auto;
}
img {
border: 1px solid brown;
}
</style>
<script>
function changeColumns(){
document.getElementById("DIV1").style.columns="10px 3";
document.getElementById("Sample").innerHTML="The columns are now modified";
}
</script>
</head>
<body>
<div id="DIV1">
<img src="https://www.tutorialspoint.com/images/xamarian.png"><br/>
<img src="https://www.tutorialspoint.com/images/pl-sql.png"><br/>
<img src="https://www.tutorialspoint.com/images/asp-net.png"><br/>
<img src="https://www.tutorialspoint.com/images/powerbi.png"><br/>
<img src="https://www.tutorialspoint.com/images/Tableau.png"><br/>
<img src="https://www.tutorialspoint.com/images/Big-Data-Analytics.png"><br/>
<img src="https://www.tutorialspoint.com/images/home_time_series.png"><br/>
<img src="https://www.tutorialspoint.com/images/microsoftproject.png"><br/>
</div>
<p>Change the above div columns property by clicking the below button</p>
<button onclick="changeColumns()">Change Columns</button>
<p id="Sample"></p>
</body>
</html> ผลลัพธ์

เมื่อคลิกปุ่ม “เปลี่ยนคอลัมน์ ปุ่ม −
