Example: CSS make the mouse after changing the table background properties

Source: Internet
Author: User
css| mouse This tutorial will teach you how to change the background color of a table when you move the mouse over a table (cell).


First, create a menu on your page, and then create two color bodies for authentication: one is the initial color of the table, and the other is the background color that is generated when the mouse moves over the table. In my case, the color of the background effect I used by default (when the mouse is over) is: #999999, the initial color is: #CCCCCC.

Now copy the following code to the head of the document. (located between <HEAD></HEAD> tags)
<style type= "Text/css" >
Td.off {
Background: #CCCCCC;
}

td.on{
Background: #999999;
}
</style>
Change blue to the color you need.

Td. offRefers to the initial color of the table, where the initial value set is #cccccc.
Td. onRefers to the color that is displayed when the mouse is moved over the table, and the value set here is dark Gray (#CCCCCC).

Now, what we need to do is apply this CSS code to the table you've created. Insert the following code into each <td> label in the table. class= "Off"

The added code looks like this:
&LT;TD class= "Off" >menu 1</td>
Let's get to the next line of code:
&LT;TD class= "Off"-assigns a value to the off class of the CSS for each column cell in the table, meaning that the initial color for each column cell in the table is: #CCCCCC.

--the effect of the CSS when you move the mouse over each column of cells in the table.

>--the effect of the CSS when the mouse moves away from each column cell in the table.

The entire code for the diagram example above is as follows:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<title>table Background change</title>
<style type= "Text/css" >
Td.off {
Background: #CCCCCC;
}
Td.on {
Background: #999999;
}
</style>
<body>
<table width= "cellpadding=" "3" >
<tr>
&LT;TD class= "Off"
><font color= "#000000" size= "1" >menu
1 </font></td>
</tr>
<tr>
&LT;TD class= "Off"
><font color= "#000000" size= "1" >menu
2 </font></td>
</tr>
<tr>
&LT;TD class= "Off"
><font color= "#000000" size= "1" >menu
3</font></td>
</tr>
<tr>
&LT;TD class= "Off"
><font color= "#000000" size= "1" >menu
4 </font></td>
</tr>
</table>
</body>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.