iOS safari 输入插入符号颜色

2024-04-29

我在 iPhone 设备上使用 Safari 时遇到了一个 CSS 小问题。我的搜索输入是蓝色的,当用户关注它时,插入符号几乎看不见:

在所有桌面浏览器中,它都有正确的颜色(白色),即使在桌面 Safari 上也是如此。知道如何修复此问题并更改 iOS 设备上的插入符号颜色吗?

输入样式:

input {
  background-color: $stateBlue;
  height: $navbarItemHeight;
  padding: 0 10px;
  vertical-align: bottom;
  color: $white;
  border-radius: $borderRadius;
  font-size: 1.1666666667em; // 16px
  -moz-appearance:none;
  -webkit-appearance:none;

  &::-webkit-input-placeholder {
    text-shadow: none;
    -webkit-text-fill-color: initial;
  }
}

有一个W3C规范 https://www.w3.org/TR/css-ui-3/#caret-color对于这个称为caret-color https://developer.mozilla.org/en-US/docs/Web/CSS/caret-color可以这样使用:

input[type="text"].custom {
  caret-color: red;
}
<div>
  <label>default caret:</label>
  <input type="text"/>
</div>
<div>
  <label>custom red caret:</label>
  <input type="text" class="custom"/>
</div>

It's 目前支持 https://caniuse.com/#feat=css-caret-color通过 Chrome(也在 Android 上)、Firefox、Opera 和 Safari(包括 iOS)。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

iOS safari 输入插入符号颜色 的相关文章

随机推荐