【发布时间】:2021-06-10 18:13:17
【问题描述】:
我必须写“Name * :”,其中 astrix 将是红色的。 我正在创建标签为:
{!! Form::label("name","Name".<span class="red">*</span>." :") !!}
但这会导致:Name with html tag span tag。
谢谢
【问题讨论】:
我必须写“Name * :”,其中 astrix 将是红色的。 我正在创建标签为:
{!! Form::label("name","Name".<span class="red">*</span>." :") !!}
但这会导致:Name with html tag span tag。
谢谢
【问题讨论】:
为此,您必须传递array。如下所示:
{!! Form::label("name", "Name:", array('class' => 'require') !!}
并在下面设置这个require 类的样式。希望这应该有效。
.require:after{
content:'*';
color:red;
}
另一种方式,已更新:
我想,这就是你要找的。在span 中使用双引号,在style 中使用单引号。
{!! Form::label('name', 'Name:'),"<span style='color:red'>*</span>" !!}
这应该可行。
【讨论】:
使用这个:
label.required:after {
color: red;
content: "* :";
}
{!! Form::label("name","Name", array('class' => 'required')) !!}
【讨论】:
使用array 作为第三个参数:
{!! Form::label("name", "Name", array('class' => 'redast')) !!}
CSS 将是:
.redast{
color: #000000;
}
.redast:after{
color: #FF0000;
content: '*';
}
http://www.w3schools.com/cssref/pr_gen_content.asp
另外,为什么不使用这样的东西:
<div>
<span>{!! Form::label("name", "Name") !!}</span>
<span style="color:red;"> *</span>
<span> :</span>
</div>
【讨论】:
您可以使用 css 样式添加 astrix,也可以创建自己的宏来显示您需要的任何内容:
Form::macro('myCustomLabel', function($inputName){
return "<label for='$inputName'>Name<span class="red">*</span></label>";
});
查看这个链接,很有帮助:http://laravel-recipes.com/recipes/173/creating-form-macros
问候!
【讨论】:
不要使用任何逗号,只需像这样在名称或标签后附加跨度即可。
{!! Form::label("name","Name <span class='red'>*</span> :") !!}
【讨论】: