css div and javascript application---------Two methods of image transformation when the mouse passes over_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:32:24
Original
1015 people have browsed it

Whether the mouse passes through a hyperlink or a layer, it can be achieved

javascript method: Familiar with using document.getElementById() to obtain the node object


< head >
< style >
.div_n {
width : 300px ;
height : 250px ;
border : 1px solid gray ;
}

< script type =" text/javascript" >
function changeSrc1()
{
document.getElementById( " myImage " ).src = " /images/2.gif "
}
function changeSrc2()
{
document.getElementById( " myImage " ).src = " /images/1.gif "
}



< body >
< div class ="div_n" >
< a href ="http://www.baidu.com" >
< img id ="myImage" src ="/images/1.gif" onmouseover ="changeSrc1()" onmouseout ="changeSrc2()" />





css div method: Reasonably control the style of the layer


< head >
< title > New Document
< style >
.main {
width : 300px ;
height : 250px ;
border : 1px solid gray ;
}
.content {
width : 15 0px ;
height : 160px ;
border: 1px solid gray;
background-image: url(images/2.gif);
background-repeat: no-repeat;
}
.content:hover {
background -image: url(images/3.jpg);
}
a {
text-decoration: none; >

< body >
< div class ="main" >
< a href ="http://www.baidu.com/" >< div class ="content" >





source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template