Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> HTML

คุณสมบัติ columnRuleColor ของ HTML DOM Style: สีเส้นกั้นคอลัมน์

คุณสมบัติ 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
RGBrgb(255, 0, 0)
RGBArgba(255, 0, 0, 0.5)
HSLhsl(0, 100%, 50%)
HSLAhsla(0, 100%, 50%, 0.5)
currentColorใช้ค่า color ขององค์ประกอบ (ค่าเริ่มต้น)

คุณสมบัติ Column Rule ที่เกี่ยวข้อง

คุณสมบัติคำอธิบาย
columnRuleWidthความกว้างเส้นกั้น
columnRuleStyleรูปแบบเส้นกั้น
columnRuleColorสีเส้นกั้น (คุณสมบัตินี้)
columnRuleShorthand: 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)