gpt4 book ai didi

css - 按列对齐两个 Bootstrap 表?

转载 作者:可可西里 更新时间:2023-11-01 00:39:16 25 4
gpt4 key购买 nike

我目前正在使用 bootstrap 和 laravel 表单控件来创建下面的这些表结构。我现在遇到的唯一问题是我无法弄清楚如何从两个单独的表中获取删除和编辑按钮来排列?附件是它现在的样子的照片以及显示表格的代码。

enter image description here

@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

在此先感谢您,如果您能帮助我排列两个不同表格的列,我们将不胜感激!

最佳答案

我会使用 Bootstrap 4 sizing utils在表格标题列上设置定义的宽度...

<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

但是,仍然不能保证 td 列宽不会根据其内容而改变。这只是使用单独表格的结果。

关于css - 按列对齐两个 Bootstrap 表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50947631/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com