方法1: 优先


<div style="overflow-x:auto;">
<table>
... table content ...
</table>
</div>

方法2:

To create a horizontal scroll for a table on a mobile device, you would need to use the overflow-x property set to auto or scroll. Here's a sample code:


<div class="table-container">
<table>
<!-- Table content goes here -->
</table>
</div>

And the corresponding CSS:
cssCopy code.table-container {
width: 100%; /* This will make the container take full width of its parent */
overflow-x: auto; /* This will add the horizontal scrollbar when needed */
}

table {
min-width: 600px; /* This should be adjusted according to the minimum width you want for your table */
}

In this example, the table will display a horizontal scrollbar when the width of the table is larger than the container's width. Adjust the min-width value of the table according to your requirements.
The .table-container could be any parent element of the table, such as a div. The key is to set overflow-x: auto; on the parent to enable horizontal scrolling when the child element (in this case, the table) exceeds the width of the parent.
This approach can be used to make any element scrollable, not just tables. It is a common solution for making tables responsive.

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注