Osa*_*med 5 html css laravel tailwind-css
我有如下图所示的表格,它从右侧溢出,如何添加滚动,我正在使用 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>
Run Code Online (Sandbox Code Playgroud)
Ali*_*deh 10
用带有overflow-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>
Run Code Online (Sandbox Code Playgroud)