CSS + DIV enables the background color of the mouse to pass through the background

Source: Internet
Author: User

There are many ways to change the background color of the mouse. Today we will introduce how to use CSS + DIV.

Method 1

 

Reference content is as follows:

# Div: hover {background: #000000 ;}

Explanation: background color changes when the mouse passes through an element with the id div

IE6.0, Firefox2.0, and Opera 9.23 are unavailable.

Method 2

 

Reference content is as follows:

<Div onmouseover = "this. style. backgroundColor = '# F4F9FD'" onmouseout = "this. style. backgroundColor = '# ffff'"> </div>

Method 3:

 

Reference content is as follows:

<Style>
. D_over {background-color: #307172 ;}
. D_out {background-color: # EFEFEF ;}
</Style>

<Div class = "d_out" onmouseover = "this. className = 'd _ over'" onmouseout = "this. className = 'd _ out'"> Haha </div>

<A> labels are acceptable. However, this will lead to other labels with <a> labels changing.

Generally, <a> is used to define the link style, not a specific area. Currently, the commonly used div + css web page is used. div indicates the meaning of the Region. You still like to use this type. Of course, if you use table, there will be a simpler method.

 

In fact, most of them are implemented using the <a> label.

 

Reference content is as follows:

<Style>
A {color: red; width: 100px; height: 22px; line-height: 22px ;}
A: hover {background: # f4f4f4; color: #000 ;}
</Style>

In this way, all connections in a certain area will change. You can use them in a certain area, and the mouse will change color.

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.