HTMLInputElement: width 屬性
HTMLInputElement 介面的 width 屬性指定了控制元件的寬度。它反映了 <input> 元素的 width 屬性。
width 屬性僅對 image 型別有效。它以畫素為單位定義了影像按鈕的首選水平尺寸。屬性值是渲染按鈕的 內容框 的寬度。影響控制元件尺寸的 CSS 盒模型屬性具有優先權。
如果未設定 width 且沒有 CSS width 屬性影響控制元件,則 width 將是影像的內在寬度。如果影像未載入,則該值將是 alt 文字的最大內在寬度。如果寬度未知,width 將為 0;如果未設定 width、未應用 CSS 尺寸、未載入影像,並且 alt 的值為空字串或未設定 src。
值
一個數字。
示例
js
const inputElement = document.getElementById("imageButton");
console.log(inputElement.width);
規範
| 規範 |
|---|
| HTML # dom-input-width |
瀏覽器相容性
載入中…
另見
HTMLInputElement.heightHTMLInputElement.srcHTMLInputElement.altHTMLButtonElement<button><input><img>- CSS
inline-size屬性 - CSS
width屬性 - CSS
aspect-ratio屬性 - CSS 盒模型尺寸模組