Input Box centered on <td>

Asked

Viewed 129 times

0

I’d like to know how to center inputs in the code below.

@foreach ($riscos as $risco)
          <tr>
          <th class="row-header">{{ $risco->risk}}</th>
          @for ($i = 0; $i < 14; $i++)
            <td style="text-align: center; vertical-align: middle;">
            <form>
              <div class="form-group">
                <input type="email" class="form-control" id="exampleFormControlInput1" placeholder="" style="width: 30px;" text-align="center">
              </div>
            </form>
          </td>
          @endfor
        @endforeach

It’s getting like this: https://i.imgur.com/u43wdwY.png

1 answer

0


Here’s a simple option, first I NEVER change the display of no element related to table, then never change for example a td or th for display:flex for example.

That said, enjoy this div who has the input in and work with him, I used display:grid in it next to a place-items: center and resolved.

td,
th {
    width: 80px;
    height: 80px;
    border: 1px solid #000;
}

.form-group {
    display: grid;
    place-items: center;
}
<table>
    <tr>
        <th class="row-header">{{ $risco->risk}}</th>
    </tr>
    <tr>
        <td style="text-align: center; vertical-align: middle;">
            <form>
                <div class="form-group">
                    <input type="email" class="form-control" id="exampleFormControlInput1" placeholder="" style="width: 30px;" text-align="center">
                </div>
            </form>
        </td>
    </tr>
</table>

Browser other questions tagged

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