คุณสมบัติ HTML DOM columnRule ใช้สำหรับรับหรือตั้งค่าคุณสมบัติ columnRule เป็นคุณสมบัติชวเลขสำหรับจัดการคุณสมบัติสามอย่างชื่อcolumnRuleColor, columnRuleStyleและ columnRuleWidth
ต่อไปนี้เป็นไวยากรณ์สำหรับ −
การตั้งค่าคุณสมบัติ columnRule -
object.style.columnRule = "column-rule-width column-rule-style column-rule-color|initial|inherit"
อธิบายคุณสมบัติข้างต้นดังนี้ −
| ค่า | คำอธิบาย |
|---|---|
| columnRuleWidth | สำหรับกำหนดความกว้างของกฎระหว่างคอลัมน์ มันถูกตั้งค่าเป็นสื่อโดยค่าเริ่มต้น |
| columnRuleStyle | Fสำหรับการตั้งค่ารูปแบบกฎระหว่างคอลัมน์ มันถูกตั้งค่าเป็น none โดยค่าเริ่มต้น |
| columnRuleColor | สำหรับการตั้งค่ารูปแบบกฎระหว่างคอลัมน์ มันถูกตั้งค่าเป็น none โดยค่าเริ่มต้น |
| columnRuleColor | สำหรับกำหนดสีกฎระหว่างคอลัมน์ มันถูกตั้งค่าเป็นค่าสีขององค์ประกอบโดยค่าเริ่มต้น |
| เริ่มต้น | สำหรับการตั้งค่าคุณสมบัตินี้เป็นค่าเริ่มต้น |
| สืบทอด | การสืบทอดค่าคุณสมบัติหลัก |
ให้เราดูตัวอย่างสำหรับคุณสมบัติ columnRule -
ตัวอย่าง
<!DOCTYPE html>
<html>
<head>
<style>
#DIV1 {
column-count: 4;
column-rule: 4px dashed darkolivegreen;
}
</style>
<script>
function changeColumnRule(){
document.getElementById("DIV1").style.columnRule="10px solid red";
document.getElementById("Sample").innerHTML="The column rule properties are now modified";
}
</script>
</head>
<body>
<div id="DIV1">
<img src="https://www.tutorialspoint.com/images/Swift.png"><br/>
<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/microsoftproject.png">
</div>
<p>Change the above div column rule properties by clicking the below button</p>
<button onclick="changeColumnRule()">Change Column Rule</button>
<p id="Sample"></p>
</body>
</html> ผลลัพธ์

เมื่อคลิกที่ “เปลี่ยนกฎของคอลัมน์” ปุ่ม −
