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

Thuộc tính columnRuleWidth trong HTML DOM Style

Thuộc tính columnRuleWidth dùng để thiết lập hoặc lấy độ dày đường phân cách giữa các cột.

Cú pháp

object.style.columnRuleWidth = "medium|thin|thick|length|initial|inherit"

Giá trị tham số

Giá trịMô tả
thinĐường mỏng
mediumĐường trung bình (mặc định)
thickĐường dày
lengthĐộ dày cụ thể (px, em, rem...)
initialGiá trị mặc định
inheritKế thừa từ phần tử cha

Ví dụ minh họa

<!DOCTYPE html>
<html>
<head>
<style>
  #DIV1 {
    padding: 5px;
    column-count: 5;
    column-rule-width: 9px;
    column-rule-color: lightblue;
    column-rule-style: solid;
  }
</style>
<script>
  function changeColumnRuleWidth() {
    document.getElementById("DIV1").style.columnRuleWidth = "3px";
    document.getElementById("Sample").innerHTML = "Độ dày column rule đã được giảm xuống";
  }
</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>Thay đổi column rule width của div trên bằng cách nhấn nút dưới đây</p>
<button onclick="changeColumnRuleWidth()">Thay đổi Column Rule Width</button>
<p id="Sample"></p>
</body>
</html>

Kết quả

Ban đầu đường phân cách dày 9px solid lightblue. Sau khi nhấn nút, giảm còn 3px.