【问题标题】:Rails 4 / Ruby 2 how to put the label in the inputRails 4 / Ruby 2如何将标签放入输入中
【发布时间】:2014-02-07 22:21:42
【问题描述】:

在 rails 4 和 ruby​​ 2 中,为了给表单留出更多空间,如何将标签的标题放在输入中?

谢谢

【问题讨论】:

  • 你的意思是占位符吗?我的意思是说,当显示输入框时,用默认值填充该字段。在这种情况下,只需添加:placeholder => "label"

标签: ruby forms input ruby-on-rails-4 label


【解决方案1】:

就像 Kirti 说的你可以使用占位符,但如果你真的想要一个标签,你可以使用 label_tag or label

【讨论】:

    【解决方案2】:

    你可以使用“label_tag”,这就是你想要的:

    label_tag 'name', 'Your name'
    # will output => <label for="name">Your name</label>
    

    label_tag

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-21
      • 1970-01-01
      • 2013-09-16
      • 1970-01-01
      • 2020-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多