javascripthtmlcsssearch

Override the -webkit-search-cancel-button


I'm trying to override the small (x) that appears in the search bar, to have it do more than clear the search

Currently this is my search bar: HTML:

<input type="search" class="form-control" id="inputSearch" placeholder="Search for node" onchange="searchForNode(this)"></div>

CSS:

#inputSearch::-webkit-search-cancel-button{
    position:relative;
    right:20px;    
}

Any ideas?


Solution

  • DEMO

    1) Mozilla treats search inputs as text. For Webkit browsers however (Chrome, Safari), the search input is styled as a client created HTML

    2) for chrome

    CSS

    Article link

    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) */
    
    }
    

    Similar Question