[英]Rails CSS - different styles in a single generated text input field
I have a rails 4 app using simple form. 我有一个使用简单表单的Rails 4应用程序。
I have a form input field called :content. 我有一个名为:content的表单输入字段。 It is a text field.
它是一个文本字段。
I want to be able to apply different styling to important parts of the text inside the content field, and to show links differently to text. 我希望能够对内容字段内的文本的重要部分应用不同的样式,并显示与文本不同的链接。
I tried making SCSS items as follows: 我尝试制作SCSS项目,如下所示:
.intpol1 {
font-family: 'Roboto', sans-serif;
color: black;
font-size: 36px;
text-align:left;
line-height: 2;
}
.intpol2 {
font-family: 'Roboto', sans-serif;
color: black;
font-size: 26px;
text-align:left;
line-height: 1.5;
}
.intpol3 {
font-family: 'Roboto', sans-serif;
color: black;
font-size: 16px;
text-align:left;
}
.intpollink {
font-family: 'Roboto', sans-serif;
color: black;
font-size: 16px;
text-align:left;
color: #E50851;
}
And then in my form, I try applying them as follows: 然后在我的表单中,尝试按如下所示应用它们:
<div class="intpol1"> Test</div> <div class="intpol3"> Test3</div> <div class="intpol2"> Test2</div> <div class="intpollink"> Testlink</div>
What I was hoping to achieve was the CSS styling would apply to the text fields instead of rendering the div tags in the html output. 我希望实现的是CSS样式将应用于文本字段,而不是在html输出中呈现div标签。
Is there a way of making a form input field so that its possible to use CSS on segments of the form content? 有没有一种方法可以使表单输入字段成为可能,从而可以在表单内容的段上使用CSS?
Unfortunately, that's not possible. 不幸的是,这是不可能的。 You can't place any child elements inside
<input>
. 您不能在
<input>
内放置任何子元素。 To achieve something like this you need to use multiple <input>
elements, and style each one of them. 为了实现这样的目标,您需要使用多个
<input>
元素,并对每个元素进行样式设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.