Bootstrap: pull left and right in panel footer breaks footer

HtmlCssTwitter Bootstrap

Html Problem Overview


I have a a Bootstrap panel with two buttons in the footer:

    <div class="panel-footer">
        {{ Form::open( array('route' => array('dogs.edit', $dog->id), 'method' => 'get', "class" => 'col-lg-6 ')) }}
            {{ Form::submit("Edit", array('class' => 'btn btn-default')) }}
        {{ Form::close() }}
        {{ Form::open( array('route' => array('dogs.destroy', $dog->id), 'method' => 'delete', "class" => 'col-lg-6 ')) }}
            {{ Form::submit("Delete", array('class' => 'btn btn-default')) }}
        {{ Form::close() }}
    </div>

The forms for each of the buttons have the class pull-left and pull-right so that they are each floated to either side of the panel footer.

The float is working, but the buttons are now outside of the footer:

enter image description here

I tried using the grid system instead of the pull helpers but I ended up with the same result.

I've also searched around for the solution (this has to be pretty common I would think) and haven't found an explanation that doesn't require overriding Bootstrap with custom css.

Is it possible to fix this with just Bootstrap or would I need to throw my own css in to fix it?

Html Solutions


Solution 1 - Html

Just add a div with clearfix after the buttons

<div class="clearfix"></div>

Solution 2 - Html

stalin's answer is correct, but you can use another approach that is more elegant

From Bootstrap Documentation (#clearfix)

> Easily clear floats by adding .clearfix to the parent element.

Just add clearfix to the parent div:

<div class="panel-footer clearfix">
    {{ Form::open( array('route' => array('dogs.edit', $dog->id), 'method' => 'get', "class" => 'col-lg-6 ')) }}
        {{ Form::submit("Edit", array('class' => 'btn btn-default')) }}
    {{ Form::close() }}
    {{ Form::open( array('route' => array('dogs.destroy', $dog->id), 'method' => 'delete', "class" => 'col-lg-6 ')) }}
        {{ Form::submit("Delete", array('class' => 'btn btn-default')) }}
    {{ Form::close() }}
</div>

Solution 3 - Html

just add the class text-right on the panel-footer div

Solution 4 - Html

I think its strange that .panel-footer isn't included in the clearfix css library already the way .panel-body and even .modal-footer are. Instead of having to remember to throw a clearfix class on ever footer (if you have a lot it can be a pain) its better to just add the clearfix css to .panel-footer in your master CSS or edit the library directly.

.panel-footer:before, .panel-footer:after {
	display: table;
	content: " ";
}
.panel-footer:after {
	clear: both;
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionChris SchmitzView Question on Stackoverflow
Solution 1 - HtmlstalinView Answer on Stackoverflow
Solution 2 - HtmllborgavView Answer on Stackoverflow
Solution 3 - HtmlGianluca GhettiniView Answer on Stackoverflow
Solution 4 - Htmlsean6bucksView Answer on Stackoverflow