【发布时间】:2011-11-14 22:29:42
【问题描述】:
如何在 html 表单中将输入字段的占位符对齐居中?
我正在使用以下代码,但它不起作用:
CSS ->
input.placeholder {
text-align: center;
}
.emailField {
top:413px;
right:290px;
width: 355px;
height: 30px;
position: absolute;
border: none;
font-size: 17;
text-align: center;
}
HTML ->
<form action="" method="POST">
<input type="text" class="emailField" placeholder="support@socialpic.org" style="text-align: center" name="email" />
<!<input type="submit" value="submit" />
</form>
【问题讨论】:
-
不是一个真正的答案,但 jQuery Mobile 会这样做,所以你可能想看看他们是如何实现它的。
-
对我来说,当您摆脱
input.placeholder位时,您的代码就可以工作。将输入中的文本对齐到中心也会对齐占位符。