html-如何在桌面设备和移动设备之间修复不一致的占位符文本垂直对齐方式?

我输入的占位符文本在Firefox和Chrome桌面中正确垂直对齐.但是在Safari桌面以及Firefox Mobile,Chrome Mobile和Safari Mobile上,文本太高了.

我已经尝试过使用padding和line-height,但是还无法解决.

这是代码-在移动设备上查看以查看问题:

https://codepen.io/paulspelman/pen/XGvVrE

* {
  -webkit-Box-sizing: border-Box;
  Box-sizing: border-Box;
}

body {
  padding: 0;
  margin: 0;
  color: #00bb80;
  background: #101010;
}

.wrapper {
  display: -webkit-Box;
  display: -ms-flexBox;
  display: flex;
  -webkit-Box-orient: vertical;
  -webkit-Box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  -webkit-Box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
  margin: 0 auto;
  max-width: 900px;
  font-family: sans-serif;
  text-align: center;
  width: 70%;
}

.input-holder {
  position: relative;
  display: -webkit-Box;
  display: -ms-flexBox;
  display: flex;
  -webkit-Box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  -webkit-Box-align: center;
  -ms-flex-align: center;
  align-items: center;
  height: 4rem;
  margin: 0 auto 2rem auto;
}

input {
  height: 4rem;
  width: 12rem;
  font-size: 2rem;
  font-weight: 300;
  text-align: left;
  padding: 0 0 0.2rem 1rem;
  margin-left: 0.5rem;
  color: #9b9b9b;
  background: #101010;
  border: 1px solid #434343;
  border-right: 0;
  border-radius: 0;
}

input::-webkit-input-placeholder {
  font-size: 1.1rem;
  font-weight: 400;
  position: relative;
  top: -0.3rem;
  color: #9b9b9b;
}

input:-ms-input-placeholder {
  font-size: 1.1rem;
  font-weight: 400;
  position: relative;
  top: -0.3rem;
  color: #9b9b9b;
}

input::-ms-input-placeholder {
  font-size: 1.1rem;
  font-weight: 400;
  position: relative;
  top: -0.3rem;
  color: #9b9b9b;
}

input::placeholder {
  font-size: 1.1rem;
  font-weight: 400;
  position: relative;
  top: -0.3rem;
  color: #9b9b9b;
}

.dollar-sign {
  color: #9b9b9b;
  font-size: 2rem;
  font-weight: 300;
  margin: 0;
  padding-bottom: 0.4rem;
}

button {
  height: 4rem;
  font-size: 1.5rem;
  width: 4rem;
  font-weight: 400;
  text-align: center;
  background-color: #797979;
  color: #101010;
  border: 0;
  padding: 0;
}
<div class="wrapper"> 


    <div class="input-holder">
        <p class="dollar-sign">$</p>
        <input type="text" class="user-input" placeholder=" Placeholder text" maxlength="4" value="" autocomplete="off">
        <button class="calculate-button">&rarr;</button>
    </div>

</div>
最佳答案
一个小的hack可以修复它.您需要指定:

@supports(font-synthesis: inherit) { // not supported by Chrome but supported by Safari
   input::placeholder {
     line-height:3em
  }
}

Demo

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Mip是什么意思以及作用有哪些
怎么测试Mip页面运行情况
MIP安装的具体步骤有哪些
HTML添加超链接、锚点的方法及作用详解(附视频)
MIP的规则有哪些
Mip轮播图组件中的重要属性讲解
Mip的内联框架组件是什么
怎么创建初始的MIP配置及模板文件
HTML实现多选框及无法提交多数据的原因分析(附视频)
HTML如何设置复选框、单选框以及默认选项?(图文+视频)
怎么使用MIP组件
Div垂直居中效果怎么实现
HTML如何实现视频在线播放
如何使用Mip代码校验工具
Mip中弹出层组件是什么
如何用HTML实现简单按钮样式
Mip中快速回顶组件怎么用
Div内容居中效果如何实现
Div水平居中效果怎么实现
Mip中列表组件怎么用