HTML5 在占位符 jQuery

HTML5 in Placeholder jQuery

我想在我的 input placeholder 中有一个 bold tag,如下所示:


|--------------------|
|  BOLD normal       |
|--------------------|

我在 Google 上找到了答案,但没有用。就像用 position:relative.

input 上覆盖 div

有没有办法在 placeholder 标签中包含 HTML 而无需 HTML?比如有用的jQuery插件? Chrome.

以外的任何浏览器都不需要支持它

占位符内不能有粗体 "tag"。但是,您可以通过某种方式设置样式,使某些文本变为粗体。但是,您只能对文本的开头或结尾设置样式。

input {
  padding: 5px 10px;
  width: 500px;
}

input::-webkit-input-placeholder {
  font-weight: bold;
  color: red;
}

input::-webkit-input-placeholder:after {
  content: " Not so bold here";
  font-weight: normal;
  color: blue;
}
<input type="text" placeholder="I'm a pretty bold placeholder text..">

http://codepen.io/anon/pen/WryaPM

试试这个...

div.input { border:1px solid #aaa; width:300px; }
<div contenteditable="true" class="input"><strong>My name is:</strong> devat karetha</div>