ruby 中字符串占位符的换行符 [英] line break for a string placeholder in ruby

查看:112
本文介绍了ruby 中字符串占位符的换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<%= f.text_area :comment, placeholder: "Comment on your track or" + \n + "share your favorite lyrics" %>

我怎样才能让占位符像

How can I get the placebolder to line break like

解决方案只是添加空格以便下一行换行:

Solution was just to add white space so the next line wraps:

placeholder: "Comment on your track or                         share your favorite lyrics" %>

相当丑陋但最不复杂

推荐答案

换行符 \n 应该包含在 double 之间,然而 HTML 不允许换行,但 Thomas Hunter 建议使用hack 包括使用一堆空格,如下所示:

The newline character \n should be included between the double, however HTML does not allow for line feed, but Thomas Hunter suggested an hack which consists in using a bunch of white spaces, like so:

<%= f.text_area :comment, placeholder: "Comment on your track or                  share your favorite lyrics" %>

您也可以选择使用 title 属性.

You can also opt to use the title attribute instead.

这篇关于ruby 中字符串占位符的换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆