input type型別與定義的寬高

2021-07-10 07:08:26 字數 964 閱讀 6031

近來,在寫input表單時候,忽然發現乙個問題,那就是:雖然input可以設定寬高,在設定width和height相同時,當type型別不同,其對應的寬高效果也完全不一致,先上**:

lang="en">

charset="utf-8">

testtitle>

type="text/css"

rel="stylesheet">

div, input

style>

head>

divdiv>

type="button"

value="button">

type="submit"

value="submit">

type="text"

value="text">

type="password"

value="password">

body>

html>

剛開始,我以為四種形式的input的大小是一樣的,但是經過驗證後,發現效果並不完全相同,type="button"和type="submit"效果一樣, type="text" 和type="password"效果一樣,先上圖:

![效果一](

很明顯,可以看出型別為「button」和「submit」時,看起來要小很多,除錯網頁時,其效果是這樣的,當input型別「button」和「submit」時:

![效果2](

當input型別「text」和「password」時:

![效果3](

所以,當input 型別為"button"和type="submit",設定的 width="實際看到的大小"+padding+border;當input 型別為"text"和type="password",實際看到的大小=width+padding+border;

更改 input type 的值

需要實現的效果 乙個輸入框,當輸入框未獲得焦點的時候,value 值為 密碼 當輸入框失去焦點的時候,輸入內容顯示為 我們很直接會想到下面的js showpwd focus function 發現並沒有實現預期效果,出現 uncaught exception type property can t ...

editText中inputtype的使用屬性

文字型別,多為大寫 小寫和數字符號。android inputtype none 輸入普通字元 android inputtype text 輸入普通字元 android inputtype textcapcharacters 輸入普通字元 android inputtype textcapword...

Editext的inputType常用屬性

多行輸入,回車鍵為換行,無其他功能 inputtype填入屬性後,預設singleline true 效果,這裡除外 text 普通 textpassword 不可見密碼 textcapcharacters 字母大寫 textcapwords 首字母大寫 textcapsentences 僅第乙個字...