内联“必需”星号Laravel形式标签 [英] Inline "required" asterisk in Laravel form label

查看:355
本文介绍了内联“必需”星号Laravel形式标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Laravel的必填字段中添加一个红色星号,但我不确定如何将它们与标签内联添加。



什么我现在做的是

  {{Form :: label('took_act_or_sat','你或你会参加SAT考试吗?或ACT?')}}< span style =color:red> *< / span> 

但是当标签换行到第二行时,出于某种原因星号正在碰撞一行





所以我想我的问题的第一部分是:你可以添加内联样式到Laravel的表单标签吗?



第二个部分是:还有另一种方法,我应该加入星号(或其他标记),以便这不会是一个问题?



如果相关,我如果这也影响到了我的大部分样式,我也会使用Bootstrap。

第三个参数

  {{Form :: label('took_act_or_sat','你或你会参加SAT或ACT吗?' ,array('class'=>'required'))}} 

 < style> 
.required:after {
content:'*';
颜色:红色;
padding-left:5px;
}
< / style>


I'm trying to add a red asterisk for my required fields in Laravel, but I'm not sure how to add them inline with the label.

What I'm doing currently is

{{ Form::label('took_act_or_sat' , 'Did you or will you take the SAT or ACT?' ) }} <span style="color: red">*</span>

but when the label wraps to a second line, for some reason the asterisk is being bumped an extra line down.

So I guess the first part of my question is: Can you add inline styling to a form label in Laravel?

And the second part is: Is there another way I should be going about adding the asterisk (or other marker) so that this wouldn't be an issue?

If it's relevant, I'm also using Bootstrap for the majority of my styling if that also affects anything.

解决方案

Add a class to your label with the third parameter

{{ Form::label('took_act_or_sat' , 'Did you or will you take the SAT or ACT?', array('class' => 'required') ) }}

And add asterisk with css

<style>
    .required:after{ 
        content:'*'; 
        color:red; 
        padding-left:5px;
    }
</style>

这篇关于内联“必需”星号Laravel形式标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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