将占位符居中并在文本字段中输入文本

时间:2012-09-13 10:33:26

标签: html css

我想知道是否可以将占位符和用户将在文本字段中输入的输入居中。我想有可能我无法弄明白。有人可以帮忙吗?我所讨论的文本字段的代码如下......

<input type="text" style="font-weight:bold:" name="kword" id="kword" autofocus ="on" placeholder="Enter Keyword(s)" autocomplete ="on"/>

由于

2 个答案:

答案 0 :(得分:4)

这可以用于text-align:center

CSS:

input, input[placeholder] {
    text-align: center;
}

答案 1 :(得分:2)

定位特定于浏览器的占位符伪元素,如下所示:

&#13;
&#13;
input {
  text-align: center;
}

::-webkit-input-placeholder {
  text-align: center;
}
:-moz-placeholder {
  /* Firefox 18- */
  text-align: center;
}
::-moz-placeholder {
  /* Firefox 19+ */
  text-align: center;
}
:-ms-input-placeholder {
  text-align: center;
}
&#13;
<input type="text" style="font-weight:bold;" placeholder="Enter Keyword(s)" />
&#13;
&#13;
&#13;

相关问题