I am currently using bootstrap and laravel form control to create theses table structures below. The only issue I am running into now is that I cannot figure out how to get the delete and edit buttons from two separate tables to line up? Attached is a photo of what it looks like now as well as the code for displaying the tables.
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">Dashboard</div>
<div class="card-body">
@if (session('status'))
<div class="alert alert-success">
{{ session('status') }}
</div>
@endif
<a href="/incidents/create" class="btn btn-primary">Create Incident</a>
<a href="/servers/create" class="btn btn-primary">Create Server</a>
<h1></h1>
<h3>Your Incidents </h3>
@if($incidents)
<table class='table table-striped'>
<tr>
<th>Title</th>
<th></th>
<th></th>
</tr>
@foreach($incidents as $incident)
<tr>
<td><h4>{{$incident->title}} : <strong>{{$incident->status}}</strong></h4></td>
<td><a href="/incidents/edit/{{$incident->id}}" class="btn btn-success">Edit</a></td>
<td>
{!!Form::open(['action' => ['IncidentsController@destroy', $incident->id], 'method' => 'POST', 'class' => 'float-right'])!!}
{{Form::hidden('_method', 'DELETE') }}
{{Form::submit('Delete', ['class' => 'btn btn-danger'])}}
{!!Form::close() !!}
</td>
</tr>
@endforeach
</table>
@endif
<h3>Your Servers </h3>
@if($servers)
<table class='table table-striped'>
<tr>
<th>Server Names</th>
<th></th>
<th></th>
</tr>
@foreach($servers as $server)
<tr>
<td><h4>{{$server->name}}</h4></td>
<td><a href="/servers/edit/{{$server->id}}" class="btn btn-success">Edit</a></td>
<td>
{!!Form::open(['action' => ['ServerController@destroy', $server->id], 'method' => 'POST', 'class' => 'float-right'])!!}
{{Form::hidden('_method', 'DELETE') }}
{{Form::submit('Delete', ['class' => 'btn btn-danger'])}}
{!!Form::close() !!}
</td>
</tr>
@endforeach
</table>
@endif
</div>
</div>
</div>
</div>
</div>
@endsection
Thank you in advance and any help on how I could line up the columns for the two different tables would be much appreciated!
I would use Bootstrap 4 sizing utils to set defined widths on the table heading columns...
<table class="table table-striped">
<tbody>
<tr>
<th class="w-50">Server Names</th>
<th class="w-25"></th>
<th class="w-25"></th>
</tr>
<tr>..</tr>
</tbody>
</table>
https://www.codeply.com/go/hKnKbWhhHh
However, there's still no guarantee that the td column widths won't change depending on the their content. That's just the result of using separate tables.
Give the edit and delete <td>
's a css class forcing a maximum width. Then it won't auto spread out like that.
<td class="smallbox">
And in CSS you can just say:
.smallbox {
max-width: 40px; //or whatever
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With