为什么 input type=search 会导致 Webkit(Safari) 上的额外填充

The*_*Eks 3 css safari webkit

当使用输入时,type="search"为什么 Safari 会在字段的值/占位符的左侧添加一些额外的填充像素?

<input type="search" placeholder="Search" />
Run Code Online (Sandbox Code Playgroud)

(记得在Safari中查看)

<input type="search" placeholder="Search" />
Run Code Online (Sandbox Code Playgroud)
.input {
  padding: 8px 20px;
  -webkit-appearance: textfield;
}
Run Code Online (Sandbox Code Playgroud)

The*_*Eks 8

您需要删除-webkit-search-decoration伪元素的样式。

.input {
  padding: 8px 20px;
  -webkit-appearance: textfield;
}
.input::-webkit-search-decoration {
  -webkit-appearance: none;
}
Run Code Online (Sandbox Code Playgroud)
<div><input type="text" placeholder="Search" class="input" /></div>
<div><input type="search" placeholder="Search" class="input" /></div>
Run Code Online (Sandbox Code Playgroud)