You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CSS <input> border属性设置仅显下边框在移动端Safari表现异常

iOS Safari输入框仅显示下边框样式异常修复方案

iOS Safari 对表单控件存在默认预置样式,会自动给input元素添加系统级圆角、内置边框效果,你编写的基础边框样式未覆盖该默认行为,导致异常显示。

你只需要在原有样式中新增3行属性即可解决:

  • 添加-webkit-appearance: none:禁用Safari对input控件的默认外观渲染
  • 添加border-radius: 0:手动清除默认圆角
  • 添加box-shadow: none:避免Safari默认添加的内阴影干扰边框效果

修改后的完整代码如下:

export const TextField = styled.input`
   width: 100%;
   background: #131d32;
   -webkit-appearance: none;
   border-radius: 0;
   box-shadow: none;
   border: none;
   border-bottom: 2px solid rgba(200, 200, 200, 0.7);
   min-height: 35px;
   color: white;
   outline: 0;
   :focus {
       border-bottom-width: 1px;
   }`;

注:原有代码同时设置了border-bottom: 1px和border-width: 0 0 2px存在属性冲突,已统一调整为显式设置下边框宽度,可读性更强

内容的提问来源于stack exchange,提问作者james

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.14 13:45:03