Place border in split div

Asked

Viewed 1,707 times

2

I’m trying to put a box around my form. So far so good, but now when I intend to divide the form in half this same box around the form ceases to work.

<div class="formCreate " style="width: 95%">
    <div class="divCaixa">
        <div style="width: 50%; float: left;">
            <table border="1" style="width: 100%;">
                <tr>
                    <td>Série:</td>
                    <td>&nbsp</td>
                    <td>
                        @Html.DropDownList("Serie", (SelectList)ViewBag.Series, "", new { @class = "form-control input-sm" })
                    </td>
                    <td>&nbsp</td>
                    <td>Nº Contrato:</td>
                    <td>&nbsp</td>
                    <td>@Html.TextBoxFor(model => model.NumDoc, new { @class = "form-control input-sm", id = "NumDoc", onchange = "validaSerieNumDocExistentes()" })</td>
                </tr>

            </table>
        </div>
        <div style="width: 50%; float: right;">
            <table border="1" style="width: 100%;">
                <tr>
                    <td>asdasd</td>
                </tr>
            </table>
        </div>
    </div>
</div>

When I use the float: right to put the contents to the right happens:inserir a descrição da imagem aqui

That is, the class divCaixa no longer circumvents the body

.divCaixa {
   border: 1px solid #d5d5d5;
   padding:20px 20px 20px 20px; 
   border-radius: 1px;
   width:95%;
}
  • A script to put the size of the div to the table size, would solve?

1 answer

2


This is because the div has floating content, which is disregarded in the calculation of dimensions. Add overflow: hidden to solve:

.divCaixa {
   border: 1px solid #d5d5d5;
   padding:20px 20px 20px 20px; 
   border-radius: 1px;
   width:95%;
   overflow: hidden;
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.