Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> HTML

Thuộc tính columnRule trong HTML DOM Style

Thuộc tính columnRule là shorthand để lấy hoặc thiết lập đường phân cách giữa các cột (multi-column layout). Bao gồm 3 thuộc tính: columnRuleWidth, columnRuleStyle, columnRuleColor.

Cú pháp

object.style.columnRule = "column-rule-width column-rule-style column-rule-color|initial|inherit"

Tham số

Giá trịMô tả
columnRuleWidthĐộ dày đường phân cách (mặc định: medium)
columnRuleStyleKiểu đường phân cách (mặc định: none)
columnRuleColorMàu đường phân cách (mặc định: màu chữ phần tử)
initialGiá trị mặc định
inheritKế thừa từ phần tử cha

Ví dụ minh họa

<!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 = "Thuộc tính column rule đã được sửa đổi";
  }
</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>Thay đổi column rule của div trên bằng cách nhấn nút dưới đây</p>
<button onclick="changeColumnRule()">Thay đổi Column Rule</button>
<p id="Sample"></p>
</body>
</html>

Kết quả

Ban đầu 4 cột, đường phân cách 4px dashed darkolivegreen. Sau khi nhấn nút: 10px solid red.