Home Web Front-end JS Tutorial CSS mouse response event process, movement, click example introduction_javascript skills

CSS mouse response event process, movement, click example introduction_javascript skills

May 16, 2016 pm 05:23 PM
css

Several types of mouse trigger CSS events.
Description:
onMouseDown triggers when the mouse is pressed
onMouseOver triggers when the mouse passes over
onMouseUp triggers when the mouse is pressed and released
onMouseOut triggers when the mouse moves out
onMouseMove triggers when the mouse moves

Copy code The code is as follows:

<html>
<head>
<title>CSS mouse response event</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type ="text/css">
.Off{ background-color: #00FF66; padding:100px;}
.up{background-color: #FF0000; padding:100px}
</style> ;
</head>
<body>
<ul class=Off onMouseOut="this.className='Off'" onMouseOver="this.className='Up'">
<h4>Mouse response event switches css when the mouse moves out</h4>
<li>onMouseDown triggers when the mouse is pressed
<li>onMouseOver triggers when the mouse passes
< li>onMouseUp Triggers when the mouse is pressed and released
<li>onMouseOut Triggers when the mouse moves out
<li>onMouseMove Triggers when the mouse moves</li>
</ul>
</body>
</html>

Copy code The code is as follows:

<span style="color: red;">Change color style when the mouse passes over the table:<br></span>

Copy code The code is as follows:

<style>
table { background-color:#000000; cursor:hand; width:100%; }
td {
/*Set onmouseover event*/
onmouseover: expression(onmouseover=function (){this.style.borderColor ='blue';this.style.color= 'red';this.style.backgroundColor ='yellow'});
/*Set onmouseout event*/
onmouseout: expression(onmouseout=function (){this.style.borderColor='';this. style.color='';this.style.backgroundColor =''});
background-color:#ffffff;
}
</style>
Control the color change of every other row in the table:
Simple application:
<style type="text/css">
<!--
tr {background-color:expression((this.sectionRowIndex%2==0)?" #E1F1F1":"#F0F0F0")}
-->
Advanced application: each cell changes color
<style type="text/css">
<!- -
tr {background-color:expression((this.sectionRowIndex%2==0)?"red":"blue")}
td {background-color:expression((this.cellIndex%2= =0)?"":((this.parentElement.sectionRowIndex%2==0)?"green":"yellow"))}
-->
</style>

Add CSS file reference:
Copy code The code is as follows:

< link id="cssStyle" rel="stylesheet" type="text/css" href="../style.css" />
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article

Hot Article

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What does placeholder mean in vue What does placeholder mean in vue May 07, 2024 am 09:57 AM

What does placeholder mean in vue

How to write spaces in vue How to write spaces in vue Apr 30, 2024 am 05:42 AM

How to write spaces in vue

What does span mean in js What does span mean in js May 06, 2024 am 11:42 AM

What does span mean in js

How to get dom in vue How to get dom in vue Apr 30, 2024 am 05:36 AM

How to get dom in vue

What does rem mean in js What does rem mean in js May 06, 2024 am 11:30 AM

What does rem mean in js

How to introduce images into vue How to introduce images into vue May 02, 2024 pm 10:48 PM

How to introduce images into vue

What is the function of span tag What is the function of span tag Apr 30, 2024 pm 01:54 PM

What is the function of span tag

What language is the browser plug-in written in? What language is the browser plug-in written in? May 08, 2024 pm 09:36 PM

What language is the browser plug-in written in?

See all articles