HTML div elements shrink after adding form tag

Advertisements

I added Form tag outside of my div elements and they shrank for some reason. I’m using Bootstrap and I’m guessing it’s because I have set the main containers div to "row", when I switch it to "col" it doesn’t shrink anymore but that’s not the desired layout I want. This is my code:

<div class="row">
    {{ form()}}
    <div class="col-sm-3 col-md-3 ">
        <!-- small box -->
        <div class="small-box bg-success d-flex flex-column">
            <div class="inner">
                <h3>{{ number_format(status1, 0, '', ',') }}</h3>
                <p>აქტიური</p>
            </div>
            <div class="icon">
                <i class="ion ion-bag"></i>
            </div>
            
            <div class="align-self-center ">
                {{ submit_button("Forward", "name": "1", "class": "btn btn-primary-outline text-white text-sm", 'value':'დაწვრილებით') }}
                {{form.render('id',['value':1])}}
                <i class="fa fa-arrow-circle-right"></i>
            </div>
        </div>
    </div>
    {{ form.render('csrf', ['value': security.getToken()]) }}
    {{ end_form() }}
    <!-- ./col -->
{{ form()}}
<div class="col-sm-3 col-md-3">
        <!-- small box -->
        <div class="small-box bg-info d-flex flex-column">
            <div class="inner">
                <h3>{{ number_format(status0, 0, '', ',') }}</h3>
                <p>პასიური</p>
            </div>
            <div class="icon">
                <i class="ion ion-stats-bars"></i>
            </div>
            <div class="align-self-center">
                {{ submit_button("Forward", "name": "1", "class": "btn btn-primary-outline text-white text-sm", 'value':'დაწვრილებით') }}
                {{form.render('id',['value':0])}}
                <i class="fa fa-arrow-circle-right"></i>
            </div>
           
        </div>
</div>
{{ form.render('csrf', ['value': security.getToken()]) }}
{{ end_form() }}
<div>

This is the design :

The row below is the desired layout and thats how it was before adding the form tag, and the above row is what happens when I add the form. what is causing this and how can i fix this ? thanks for the help !!

>Solution :

From the documentation:

In a grid layout, content must be placed within columns and only columns may be immediate children of rows.

You’ve inserted a form between the row and column, so the column is now a grandchild of the row instead of a child.

Replace the div with the form instead of putting the form inside the div. Make sure you set the row class on the form.

Leave a ReplyCancel reply