H5中input輸入框如何實現原生鍵盤搜索功能

  • type="search""input的類型需要是search
  • input輸入框必須放到form表單中
  • 這樣寫input框輸入值後,會有清除按鈕,需要改變樣式,或者去除,請看下方代碼
  • input[type=search]::-webkit-search-cancel-button{
    -webkit-appearance: none; // 此處只是去掉默認的小×
    }

    自定義樣式

    input[type=search]::-webkit-search-cancel-button{
    -webkit-appearance: none;
    position: relative;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background-color: #EBEBEB;
    }
    input[type=search]::-webkit-search-cancel-button:after{
    position: absolute;
    content: 'x';
    left: 25%;
    top: -12%;
    font-size: 20px;
    color: #fff;
    }

    公告


    分享到:


    相關文章: