Thuộc tính columnRuleWidth của HTML DOM được sử dụng để thiết lập hoặc lấy chiều rộng quy tắc cột.
Sau đây là cú pháp cho -
Đặt thuộc tính columnRuleWidth -
object.style.columnRuleWidth = "medium|thin|thick|length|initial|inherit"
Các giá trị thuộc tính trên được giải thích như sau -
| Giá trị | Mô tả |
|---|---|
| mỏng | Thissp chỉ định một quy tắc mỏng. |
| phương tiện | Thissp chỉ định quy tắc phương tiện và là giá trị mặc định. |
| dày | Thissp chỉ định một quy tắc mỏng. |
| chiều dài | Công cụ này được sử dụng để chỉ định chiều rộng quy tắc theo đơn vị chiều dài. |
| tên ban đầu | Đang xác nhận thuộc tính này về giá trị ban đầu. |
| kế thừa | Kế thừa giá trị thuộc tính mẹ |
Chúng ta hãy xem một ví dụ cho thuộc tính columnRuleWidth -
Ví dụ
<!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="The column rule width is now reduced";
}
</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">
<img src="https://www.tutorialspoint.com/images/QlikView.png"><br/>
<img src="https://www.tutorialspoint.com/images/hadoop.png">
</div>
<p>Change the above div column rule width by clicking the below button</p>
<button onclick="changeColumnRuleWidth()">Change Column Rule Width</button>
<p id="Sample"></p>
</body>
</html> Đầu ra
Khi nhấp vào nút “ Thay đổi chiều rộng quy tắc cột Nút ”-