HTML DOM Link sizes 屬性


HTML DOM Link sizes 屬性返回 link 元素的 sizes 屬性值。

注意 − 只有當 rel 屬性設定為 ‘icon’ 時,才會使用 sizes 屬性

語法

語法如下 −

返回 sizes 屬性值

linkObject.sizes

示例

讓我們看一個關於 Link rel 屬性的示例 −

 即時演示

<!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>

在上面的示例中,‘style.css’ 包含 −

form {
   width:70%;
   margin: 0 auto;
   text-align: center;
}
* {
   padding: 2px;
   margin:5px;
}
input[type="button"] {
   border-radius: 10px;
}

輸出

這將產生以下輸出 −

更新於: 30-Jul-2019

122 瀏覽次數

開啟你的 職業

透過完成課程獲得認證

立即開始
廣告
© . All rights reserved.