Alex Lukinov
Alex Lukinov

Reputation: 785

How to keep checkbox and label in one line in Laravel + Bootstrap form

My view has a form. In this form I have this:

<div class="row">
    {!! Form::label('math', 'Mathematics',
                     array('class' => 'col-xs-offset-4 col-lg-2 col-xs-5 text-right')) !!}
    {!! Form::checkbox('exams[1]', '2')!!}
</div>

Now it's looks like this:

enter image description here

How to keep label and checkbox in one line?

Edit

Solved like this:

<div class="row">
    <label class="col-xs-offset-4 col-lg-2 col-xs-5 text-right">Mathematics
       {!! Form::checkbox('exams[1]', '2')!!}
    </label>
</div>

Upvotes: 0

Views: 5011

Answers (3)

Casper S
Casper S

Reputation: 954

When I run your code it's on the same line already, so you might wanna check if bootstrap is loaded.

as alternative you could add a class, like "mt10"

 {!! Form::label('math', 'Mathematics',
                 array('class' => 'col-xs-offset-4 col-lg-2 col-xs-5 text-right')) !!}
 {!! Form::checkbox('exams[1]', '2', null, array('class' => 'mt10'))!!}

And add some margin to the class (might be more or less pixels)

.mt10 { margin-top: 10px; }

Upvotes: 0

Mahfuzul Alam
Mahfuzul Alam

Reputation: 3157

Give a class or id to your field for example checkbox

{!! Form::checkbox('exams[1]', '2', false, ['class' => 'checkbox']) !!}

Now in your stylesheet code like this:

.checkbox {
   margin-top: 5px; // try +/- the pixel, check what works for you
}

Upvotes: 1

ATIKON
ATIKON

Reputation: 447

give class or style to your checkbox

{!! Form::checkbox('exams[1]', '2', ['class' => 'asad'])!!}

Upvotes: 0

Related Questions