HTML5 Search Input: No Background Image in Chrome?

前端 未结 4 787
情深已故
情深已故 2020-12-28 08:06

I have been pulling my hair out trying to get Chrome to style my search input with a background image. Firefox has no problem, but I fear it\'s because it treat

4条回答
  •  -上瘾入骨i
    2020-12-28 08:57

    The cancel button can be styled with the following

    input[type="search"]::-webkit-search-cancel-button {
    
       /* Remove default */
        -webkit-appearance: none;
    
        /* Now your own custom styles */
        height: 10px;
        width: 10px;
        background: red;
        /* Will place small red box on the right of input (positioning carries over) */
    
    }
    

    Styling can be removed using

    input[type="search"]::-webkit-search-decoration,
    input[type="search"]::-webkit-search-cancel-button,
    input[type="search"]::-webkit-search-results-button,
    input[type="search"]::-webkit-search-results-decoration {
      display: none;
    }
    

    http://css-tricks.com/7261-webkit-html5-search-inputs/

提交回复
热议问题