App下載

前端開(kāi)發(fā)input常見(jiàn)問(wèn)題有哪些?問(wèn)題總結(jié)!

猿友 2021-08-04 11:54:20 瀏覽數(shù) (1890)
反饋

今天小編和大家分享個(gè)有關(guān)于開(kāi)發(fā)基礎(chǔ)標(biāo)簽的內(nèi)容吧!那么下面我們來(lái)討論有關(guān)于:“前端開(kāi)發(fā)input常見(jiàn)問(wèn)題有哪些?”這個(gè)問(wèn)題的相關(guān)內(nèi)容吧!

1. 去掉input 在iOS中的默認(rèn)圓角和內(nèi)陰影

iOS下 input會(huì)有自帶的圓角和內(nèi)陰影,去掉方法如下:

input{
    -webkit-appearance: none;
    border-radius: 0;
}

2. 焦點(diǎn)在 input 時(shí),placeholder 沒(méi)有隱藏

input:focus::-webkit-input-placeholder{
    opacity: 0;
}

3. input 輸入框調(diào)出數(shù)字鍵盤

單獨(dú)使用type="number"時(shí),iOS調(diào)起的并不是九宮格樣式的數(shù)字鍵盤,如果需要調(diào)起九宮格的數(shù)字鍵盤需要加上 pattern="[0-9]*" 屬性:

<!-- 數(shù)字鍵盤 帶有符號(hào),非九宮格樣式 -->
<input type="number"/>

<!-- 九宮格數(shù)字鍵盤 -->
<input type="number" pattern="[0-9]*"/>

<!-- 電話號(hào)碼鍵盤 -->
<input type="tel"/>

4. 搜索時(shí),鍵盤的回車按鈕文字設(shè)定為“搜索”

解決: input 使用 type="search",放在 form 表單內(nèi)。兩者結(jié)合就能使輸入法中的回車按鈕文字變?yōu)椤八阉鳌?/p>

<form action="">
    <input type="search" />
</form>

5. 改變input placeholder顏色

::-webkit-input-placeholder { /* WebKit browsers */
  color:    #999;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
  color:    #999;
  opacity:  1;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
  color:    #999;
  opacity:  1;
}
:-ms-input-placeholder { /* Internet Explorer 10+ */
  color:    #999;
}

input::-webkit-input-placeholder, textarea::-webkit-input-placeholder { /* WebKit*/  
    color:    #666;  
}  
input:-moz-placeholder, textarea:-moz-placeholder { /* Mozilla Firefox 4 to 18 */  
    color:    #666;  
}  
input::-moz-placeholder, textarea::-moz-placeholder { /* Mozilla Firefox 19+ */  
    color:    #666;  
}  
input:-ms-input-placeholder, textarea:-ms-input-placeholder { /* IE 10+ */  
    color:    #666;  
} 

6. iOS下autofocus focus()失效的問(wèn)題

iOS下不能自動(dòng)獲取焦點(diǎn),必須是在監(jiān)聽(tīng)到用戶發(fā)出的事件的函數(shù)中執(zhí)行focus才有用,比如:

// openNotifyReplay 是click觸發(fā)的事件
openNotifyReplay = (e) => {
    this.setState({
        notifyReplayVisible: true
    }, ()=>{
        document.getElementById("replayPopupText").focus()
    })
}

到此這篇關(guān)于“前端開(kāi)發(fā)input常見(jiàn)問(wèn)題有哪些?”的文章就介紹到這了,更多有關(guān)于HTML5的內(nèi)容大家可以搜索W3Cschool進(jìn)行學(xué)習(xí)! 

0 人點(diǎn)贊