简体   繁体   English

在表单的输入字段中单独占位符文本,中间是输入字符串

[英]Separate placeholder text in form's input field with input string in the middle

I have a form field in my Rails app with a placeholder. 我的Rails应用程序中有一个带有占位符的表单字段。 I'd like to divide the placeholder when you focus on the form so that the actual input of the form sits in between it. 当您专注于表单时,我想分割占位符,以便表单的实际输入位于它之间。 So for example the placeholder would be like: 所以例如占位符就像:

Placeholder "input string" placeholder

I'd like to fashion the field so that: 我想塑造这个领域,以便:

  1. Clicking on it would place the cursor at "input" between the placeholder. 单击它会将光标放在占位符之间的“输入”处。
  2. Any text entered does not overflow over the remainder of the placeholder. 输入的任何文本都不会溢出占位符的其余部分。

Is that possible? 那可能吗?

Have you considered something like: 你考虑过这样的事情:

<label for="foo">Placeholder 
  <input id="foo" name="foo" value="input string"> placeholder</label>

combined with CSS to make the input flow with the surrounding text? 结合CSS使输入流与周围的文本? Requires zero javascript and works everywhere. 需要零javascript并且无处不在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM