0

I'm using laravel to create a form styled with bootstrap css.

{!! Form::open(['url' => '/hold', 'method' => 'POST', 'class' => 'form-horizontal']) !!}

    <div class="form-group">
        {!! Form::label($detail->name, NULL, array('class'=>'control-label')) !!}
        {!! Form::text('detail['.$detail->name.']', null, ['class' => 'controls']) !!}
    </div>

    <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
    {!! Form::submit('Hold', ['class'=>'btn btn-danger', 'style' => 'float:right;']) !!}

{!! Form::close() !!}

creates a disparity in button sizes

According to Chrome dev tools, the css selector that is overriding the .btn style rules is button, html input[type="button"], input[type="reset"], input[type="submit"]

I'm guessing that the html input class takes precedence over the btn class. I do not know how to prevent this and force btn to take precedence.

2 Answers 2

3

Wrap the whole form with a div that has a custom class - call it .form-container - and then override the style within the custom container. This is super easy if you are using Sass, not much harder if you are using CSS though.

HTML - just add custom class:

{!! Form::open(['url' => '/hold', 'method' => 'POST', 'class' => 'form-horizontal form-container']) !!}

    <div class="form-group">
        {!! Form::label($detail->name, NULL, array('class'=>'control-label')) !!}
        {!! Form::text('detail['.$detail->name.']', null, ['class' => 'controls']) !!}
    </div>

    <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
    {!! Form::submit('Hold', ['class'=>'btn btn-danger', 'style' => 'float:right;']) !!}

{!! Form::close() !!}

Sass:

.form-container {
  input[type="reset"] {
    // style here
  }
}

CSS:

.form-container input[type="reset"] {
    // style here
}
Sign up to request clarification or add additional context in comments.

2 Comments

CSS selector .form-container button didn't apply the style to the submit button. The element type is not button, it's input. I don't want to apply the style rule to all inputs in the form.
You can target a specific input within the container - I updated the code to show you how. Same pattern I explained in the answer.
0

try adding .btn-sm in your button

<button type="button" class="btn btn-primary btn-sm" data-dismiss="modal">Close</button>

1 Comment

Yup, you gave the best answer @scaisEdge

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.