The table tbody in HTML can slide up and down and left and right

The table tbody in HTML can slide up and down and left and right

When the table header is fixed, it needs to be divided into two tables: one part is thead and the other part is tbody. The specific implementation is as follows:

HTML code:

<div class="table_box_big">
<div class="table_box">
    <table>
        <thead>
        <tr>
            <th><div>Title 1</div></th>
            <th><div>Title 2</div></th>
            <th><div>Title Three</div></th>
            <th><div>Title Title Title Title Title Title Title Title Title Title 4</div></th>
            <th><div>Title Title Title Title Title Title Title Title Title Title Five</div></th>
            <th><div>Title Title Title Title Title Title Title Title Title Title Six</div></th>
        </tr>
        </thead>
    </table>
    <div class="table_tbody_box">
        <table>
            <tr>
                <td>Information 1</td>
                <td>Information 2</td>
                <td>Information Three</td>
                <td>Information Information Information Information Information Information Information Information Information Four</td>
                <td>Information Information Information Information Information Information Information Information Information Five</td>
                <td>Information information information information information information information information information information six</td>
            </tr>
            <tr>
                <td>Information 1</td>
                <td>Information 2</td>
                <td>Information Three</td>
                <td>Information Information Information Information Information Information Information Information Information Four</td>
                <td>Information Information Information Information Information Information Information Information Information Five</td>
                <td>Information information information information information information information information information information six</td>
            </tr>
            <tr>
                <td>Information 1</td>
                <td>Information 2</td>
                <td>Information Three</td>
                <td>Information Information Information Information Information Information Information Information Information Four</td>
                <td>Information Information Information Information Information Information Information Information Information Five</td>
                <td>Information information information information information information information information information information six</td>
            </tr>
            <tr>
                <td>Information 1</td>
                <td>Information 2</td>
                <td>Information Three</td>
                <td>Information Information Information Information Information Information Information Information Information Four</td>
                <td>Information Information Information Information Information Information Information Information Information Five</td>
                <td>Information information information information information information information information information information six</td>
            </tr>
            <tr>
                <td>Information 1</td>
                <td>Information 2</td>
                <td>Information Three</td>
                <td>Information Information Information Information Information Information Information Information Information Four</td>
                <td>Information Information Information Information Information Information Information Information Information Five</td>
                <td>Information information information information information information information information information information six</td>
            </tr>
            <tr>
                <td>Information 1</td>
                <td>Information 2</td>
                <td>Information Three</td>
                <td>Information Information Information Information Information Information Information Information Information Four</td>
                <td>Information Information Information Information Information Information Information Information Information Five</td>
                <td>Information information information information information information information information information information six</td>
            </tr>
            <tr>
                <td>Information 1</td>
                <td>Information 2</td>
                <td>Information Three</td>
                <td>Information Information Information Information Information Information Information Information Information Four</td>
                <td>Information Information Information Information Information Information Information Information Information Five</td>
                <td>Information information information information information information information information information information six</td>
            </tr>
            <tr>
                <td>Information 1</td>
                <td>Information 2</td>
                <td>Information Three</td>
                <td>Information Information Information Information Information Information Information Information Information Four</td>
                <td>Information Information Information Information Information Information Information Information Information Five</td>
                <td>Information information information information information information information information information information six</td>
            </tr>
        </table>
    </div>
</div>

CSS style:

.table_box_big {
 overflow-x: scroll;
 overflow-y: hidden;
 position: relative;
 height: 350px;
}
.table_box {
 overflow: hidden;
 position: absolute;
}
.table_tbody_box {
 height: 300px;
 overflow: scroll;
}
table {
 border: 1px solid #eeeeee;
}
table thead tr th {
 width: 80px;
 height: 50px;
 border-right: 1px solid #eeeeee;
 text-align: center;
 word-break: keep-all;
 padding: 2px 10px;
 background: skyblue;
}
table tbody tr td {
 width: 80px;
 height: 50px;
 border-right: 1px solid #eeeeee;
 text-align: center;
 border-bottom: 1px solid #eeeeee;
 word-break: keep-all;
 padding: 2px 10px;
}

The effect is as follows:

This is the end of this article about the fixed header of the table in html and the tbody of the table can slide up, down, left and right. For more relevant content about the fixed header of the table in html, please search the previous articles of 123WORDPRESS.COM or continue to browse the related articles below. I hope that everyone will support 123WORDPRESS.COM in the future!

<<:  Detailed explanation of the difference between adaptive and responsive analysis in vernacular

>>:  Can CSS be used like this? The art of whimsical gradients

Recommend

Several ways to center a box in Web development

1. Record several methods of centering the box: 1...

Sample code for installing Jenkins using Docker

Two problems that are easy to encounter when inst...

How to install SVN server under Linux

1. Yum installation yum install subversion 2. Con...

How to completely delete the MySQL service (clean the registry)

Preface When installing the executable file of a ...

JavaScript+html to implement front-end page sliding verification (2)

This article example shares the specific code of ...

10 very good CSS skills collection and sharing

Here, clever use of CSS techniques allows you to g...

Perfect solution to Google Chrome autofill problem

In Google Chrome, after successful login, Google ...

How to modify the MySQL character set

1. Check the character set of MySQL show variable...

JavaScript implements circular progress bar effect

This article example shares the specific code of ...

Analyze how uniapp dynamically obtains the interface domain name

background The interface domain name is not hard-...

Sample code for programmatically processing CSS styles

Benefits of a programmatic approach 1. Global con...

How to modify the ssh port number in Centos8 environment

Table of contents Preface start Preface The defau...

Realize map aggregation and scattering effects based on vue+openlayer

Table of contents Preface: Result: 1. Polymerizat...