Get the App
SLTechnology News&Howtos  ›  Development  › 

How to achieve different colors and different parity rows when the mouse passes over a table data row

Shulou Source: shulou.com Published: 2022-06-03 08:21:35 10月01日 Update

This article mainly introduces "how to realize that when the mouse passes over the table data row, the color is different and the color of the parity row is also different". In the daily operation, I believe that many people have doubts about how to realize the problem of different colors and different parity lines when the mouse passes over the table data rows. The editor consulted all kinds of materials and sorted out a simple and useful method of operation. I hope it will be helpful for you to answer the question of "how to achieve different colors and different parity rows when the mouse passes over the table data rows"! Next, please follow the editor to study!

The code is as follows:

Table test

Name

Gender

Class

Name

Male

Computer Science and Technology Class 1

Duan Meng

Male

Class one of soft workers

Duan Meng

Male

Class one of soft workers

Duan Meng

Male

Class one of soft workers

Duan Meng

Male

Class one of soft workers

/ *

To change this license header, choose License Headers in Project Properties.

To change this template file, choose Tools | Templates

And open the template in the editor.

, /

/ *

Created on: 2014-7-9, 14:24:31

Author: Administrator

, /

Body {margin:0 auto; text-align:center}

/ * if the margin of the header is set to 0, the table is centered, and if border is 0, there is no boundary * /

Table {margin:0 auto

Border:0px

Solid:#000

}

/ * set the property of the th header. If font-weight is bold, it will be shown as black and thick * /

Table tr th {height:28px

Width: auto

Line-height:28px

Background:#999

Font-weight:bold

}

Table tbody tr {

Height:28px

Line-height:28px

Text-align:center

Background:#FFF

Vertical-align:middle

}

/ *

* set the change of mouse pass color

, /

/ * use this method of csss to get odd lines and set their properties later, so as to avoid using the error-prone method of expression * /

Table tbody tr:nth-child (odd) {

Background-color: # DEDEDE

}

Table tbody tr:hover {

Background-color: # CCCCCC

}

At this point, the study on "how to achieve different colors and different parity rows when the mouse passes over table data rows" is over. I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Colors different mouse parity data tables learning methods names properties more headers help utility next code odd gender technology articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Tech Info Docker OPPO Reno vpn