คุณสมบัติ columnRuleColor ใช้สำหรับกำหนดหรือดึงค่าสีของเส้นกั้นระหว่างคอลัมน์
ไวยากรณ์ (Syntax)
object.style.columnRuleColor = "color|initial|inherit"
ค่าที่รองรับ
| ค่า | คำอธิบาย |
|---|---|
| color | ระบุสีเส้นกั้น (ชื่อสี, HEX, RGB, RGBA, HSL, HSLA) ค่าเริ่มต้น = currentColor |
| initial | ตั้งค่ากลับเป็นค่าเริ่มต้น |
| inherit | สืบทอดจากพาเรนต์ |
ตัวอย่างการใช้งาน
<!DOCTYPE html>
<html>
<head>
<style>
#DIV1 {
padding: 5px;
column-count: 5;
column-rule-width: 9px;
column-rule-style: solid;
column-rule-color: lightcoral;
}
</style>
<script>
function changeColumnRuleColor() {
document.getElementById("DIV1").style.columnRuleColor = "blue";
document.getElementById("Sample").innerHTML = "สีเส้นกั้นคอลัมน์ถูกเปลี่ยนเป็นสีน้ำเงินแล้ว";
}
</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"><br/>
<img src="https://www.tutorialspoint.com/images/QlikView.png"><br/>
<img src="https://www.tutorialspoint.com/images/hadoop.png">
</div>
<p>คลิกปุ่มเพื่อเปลี่ยนสีเส้นกั้นคอลัมน์ของ div ด้านบน</p>
<button onclick="changeColumnRuleColor()">เปลี่ยน Column Rule Color</button>
<p id="Sample"></p>
</body>
</html>
ผลลัพธ์
ก่อน: เส้นกั้นสี lightcoral (แดงอ่อน)
หลัง: เส้นกั้นสีน้ำเงิน
รูปแบบสีที่รองรับ
| รูปแบบ | ตัวอย่าง |
|---|---|
| ชื่อสี | red, blue, lightcoral, darkolivegreen |
| HEX | #ff0000, #0000ff, #f08080 |
| RGB | rgb(255, 0, 0) |
| RGBA | rgba(255, 0, 0, 0.5) |
| HSL | hsl(0, 100%, 50%) |
| HSLA | hsla(0, 100%, 50%, 0.5) |
| currentColor | ใช้ค่า color ขององค์ประกอบ (ค่าเริ่มต้น) |
คุณสมบัติ Column Rule ที่เกี่ยวข้อง
| คุณสมบัติ | คำอธิบาย |
|---|---|
| columnRuleWidth | ความกว้างเส้นกั้น |
| columnRuleStyle | รูปแบบเส้นกั้น |
| columnRuleColor | สีเส้นกั้น (คุณสมบัตินี้) |
| columnRule | Shorthand: width style color |
การใช้งานจริง
.article {
column-count: 2;
column-gap: 3rem;
column-rule: 2px solid #e0e0e0; /* เส้นกั้นนูนๆ */
}
.newspaper {
column-count: 3;
column-gap: 1.5rem;
column-rule: 1px dashed #999; /* เส้นขีดแบบหนังสือพิมพ์ */
}
.magazine {
column-count: 2;
column-gap: 2rem;
column-rule: 3px double #333; /* เส้นคู่หนา */
}
การรองรับเบราว์เซอร์
รองรับ Chrome 50+, Firefox 52+, Safari 10+, Edge 12+ (ไม่รองรับ IE)