Override the -webkit-search-cancel-button

Override the -webkit-search-cancel-button

本文关键字:-webkit-search-cancel-button the Override      更新时间:2023-09-26

我正在尝试覆盖搜索栏中出现的小(x),让它做的不仅仅是清除搜索

目前这是我的搜索栏:.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;    
}

有什么想法吗?谢谢。

演示

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

类似问题

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;
}