我有這張表,如下圖所示,它從右側溢位,如何添加滾動,我正在使用 Tailwind CSS,如下代碼所示:
<table class="table-auto overflow-scroll">
<thead>
<tr class="bg-gray-100">
<th class="w-20 px-4 py-2">No.</th>
<th class="px-4 py-2">First Name</th>
<th class="px-4 py-2">Second Name</th>
<th class="px-4 py-2">Third Name</th>
<th class="px-4 py-2">Department</th>
<th class="px-4 py-2">Stage</th>
<th class="px-4 py-2">Email</th>
<th class="px-4 py-2">Roles</th>
<th class="px-4 py-2">status</th>
<th class="px-4 py-2">University Email</th>
<th class="px-4 py-2">University Password</th>
<th class="px-4 py-2">Students Files</th>
<th class="px-4 py-2">Actions</th>
</tr>
</thead>
<tbody>
@if(isset($users)) @include('dashboard.users.partials.users_details') @endif
@if(isset($searches)) @include('dashboard.users.partials.search') @endif
@if(isset($statusSearch)) @include('dashboard.users.partials.status_search') @endif
</tbody>
</table>

uj5u.com熱心網友回復:
用具有溢位-x 類和所需寬度的 div 包裹您的表格,并將 w-full 類添加到您的表格類中。
<div class='overflow-x'>
<table class='table-auto overflow-scroll w-full'>
<thead>
<tr class='bg-gray-100'>
<th class='w-20 px-4 py-2'>No.</th>
<th class='px-4 py-2'>First Name</th>
<th class='px-4 py-2'>Second Name</th>
<th class='px-4 py-2'>Third Name</th>
<th class='px-4 py-2'>Department</th>
<th class='px-4 py-2'>Stage</th>
<th class='px-4 py-2'>Email</th>
<th class='px-4 py-2'>Roles</th>
<th class='px-4 py-2'>status</th>
<th class='px-4 py-2'>University Email</th>
<th class='px-4 py-2'>University Password</th>
<th class='px-4 py-2'>Students Files</th>
<th class='px-4 py-2'>Actions</th>
</tr>
</thead>
<tbody>
@if(isset($users))
@include('dashboard.users.partials.users_details') @endif
@if(isset($searches))
@include('dashboard.users.partials.search') @endif
@if(isset($statusSearch))
@include('dashboard.users.partials.status_search') @endif
</tbody>
</table>
</div>
uj5u.com熱心網友回復:
<div class="overflow-auto ..."></div> you can try this
tailewindcss 鏈接
uj5u.com熱心網友回復:
您可以將其全部放入具有固定寬度和高度的div中,然后使用
溢位:滾動;
像這樣
<style>
#table {
width: 50%;
height: 100%;
overflow: scroll;
}
</style>
<div id="table">
<table>
<thead>
<tr class="bg-gray-100">
<th class="w-20 px-4 py-2">No.</th>
<th class="px-4 py-2">First Name</th>
<th class="px-4 py-2">Second Name</th>
<th class="px-4 py-2">Third Name</th>
<th class="px-4 py-2">Department</th>
<th class="px-4 py-2">Stage</th>
<th class="px-4 py-2">Email</th>
<th class="px-4 py-2">Roles</th>
<th class="px-4 py-2">status</th>
<th class="px-4 py-2">University Email</th>
<th class="px-4 py-2">University Password</th>
<th class="px-4 py-2">Students Files</th>
<th class="px-4 py-2">Actions</th>
</tr>
</thead>
<tbody>
@if(isset($users)) @include('dashboard.users.partials.users_details') @endif
@if(isset($searches)) @include('dashboard.users.partials.search') @endif
@if(isset($statusSearch)) @include('dashboard.users.partials.status_search') @endif
</tbody>
</table>
</div>
當然,將寬度和高度設定為您需要的任何值。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/445108.html
上一篇:casts屬性無法更改日期格式
