Thuộc tính Kích thước liên kết DOM HTML trả về giá trị của thuộc tính kích thước của phần tử liên kết.
LƯU Ý - Thuộc tính kích thước chỉ được sử dụng khi thuộc tính rel được đặt thành ‘icon’
Cú pháp
Sau đây là cú pháp -
Trả lại kích thước giá trị thuộc tính
linkObject.sizes
Ví dụ
Hãy để chúng tôi xem một ví dụ về Liên kết liên kết tài sản -
<!DOCTYPE html>
<html>
<head>
<title>Link sizes</title>
<link id="extStyle" rel="icon" href="new.gif" sizes="10x10">
</head>
<body>
<form>
<fieldset>
<legend>Link-sizes</legend>
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var extStyle = document.getElementById("extStyle");
if(extStyle.sizes == '10x10')
divDisplay.textContent = 'The linked icon size: '+extStyle.sizes+' is not compatible';
else
divDisplay.textContent = 'Congrats! The linked icon size is compatible';
</script>
</body>
</html> Trong ví dụ trên ‘style.css’ chứa -
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
}
input[type="button"] {
border-radius: 10px;
} Đầu ra
Điều này sẽ tạo ra kết quả sau -