覆盖-webkit-search-cancel-button

4 html javascript css search

我试图覆盖搜索栏中显示的小(x),让它做的不仅仅是清除搜索

目前这是我的搜索栏:HTML:

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

CSS:

#inputSearch::-webkit-search-cancel-button{
    position:relative;
    right:20px;    
}
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?谢谢.

Pra*_*hal 12

DEMO

1)Mozilla将搜索输入视为文本.但是对于Webkit浏览器(Chrome,Safari),搜索输入的样式为客户端创建的HTML

2)用于镀铬

CSS

文章链接

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

}
Run Code Online (Sandbox Code Playgroud)

类似问题


Oli*_*r C 10

Chrome 的示例:

input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  height: 24px;
  width: 24px;
  margin-left: .4em;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23777'><path d='M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'/></svg>");
  cursor: pointer;
}
Run Code Online (Sandbox Code Playgroud)