css - 如何在 Safari 和 Chrome 中居中占位符文本?
问题描述
我有一个输入字段,我在其中为占位符文本提供了比输入文本本身更小的字体。
我为此使用了这个CSS:
input {
width:200px;
height:50px;
font-size: 30px;
text-align: center;
background-color: yellow;
text-transform: uppercase;
}
::-webkit-input-placeholder { /* Chrome/Opera/Safari */
font-size: 12px;
}
::-moz-placeholder { /* Firefox 19+ */
font-size: 12px;
}
:-ms-input-placeholder { /* IE 10+ */
font-size: 12px;
}
:-moz-placeholder { /* Firefox 18- */
font-size: 12px;
}
然而,在 Safari 中发生的情况是占位符文本更多位于输入字段的顶部,而在 Chrome 中占位符文本更多位于底部。在 Safari 和 Chrome 中,输入文本本身都是垂直居中的。如何使较小的占位符文本在 Safari 和 Chrome 中也垂直居中?
解决方案
input::placeholder{
text-align:center;
line-height:50px;
}
推荐阅读
- cloud - 我可以将openstack链接到其他服务器吗?
- html - 如何将徽标添加到简单的 CSS 汉堡菜单?
- c# - 在 Excel 文件中设置逗号不起作用
- python - 如何使输出的最后一列仅包含列表的每个元素而不是整个列表?
- docker - 如何在 docker-compose 中为 tensorflow-serving 指定“model_config_file”变量?
- c# - 访问附加到 SharePoint 中的列表项的资源
- django - [FreeTDS][SQL Server]用户登录失败
- python - 随机森林和逻辑回归显示准确率为 99%
- android - 是否可以为 Zebra 条码扫描仪设置默认应用程序?
- jhipster - jhipster 警告 org.apache.kafka.clients.NetworkClient 代理可能不可用