开发者

show-hide image onmouseover

开发者 https://www.devze.com 2022-12-27 11:45 出处:网络
I have 3 images on top of each other. The first one is a normal .jpg image, the second a greyscale version and the 3rd is some kind of effect i add with a transparent .png

I have 3 images on top of each other. The first one is a normal .jpg image, the second a greyscale version and the 3rd is some kind of effect i add with a transparent .png

Now what i want is that, if i move the mouse over those images, the greyscale image is hidden or replaced by another image and afterwards visible again.

The problem here is that i am a js noob, so it's kind of hard for me to find a solution ^^

my code looks something like this:

<html> 
<head>
<style type="text/css">
<!--                                               
ul li{                     
  display: inline-table;
}
.frame{
  position: relative;  
  height: 110px;
  width: 110px;
}  
.frame div{
  position: absolute;
  top:0px;
  left:0px;              
}       
.effect{                                           
  background:url(images/effect.png) no-repeat;
  height:110px;
  width: 110px; 
}  
.image{
  height:100px;
  width:100px;
  border: 1px solid red;
  margin:4px;    
}
.greyscale{ 
  height:100px;
  width:100px;
  border: 1px solid red;
  margin:4px;          
}    
-->
</style>
</head>

<body>
<ul>
  <li>
    <div class="frame">
      <div class="image"><img src="images/pic1.jpg" height="100" width="100"></div>      
      <div class="greyscale"><img src="images/grey1.jpg" height="100" width="100"></div>
      <div class="effect">qwert</div>
    </div>
  </li> 
  <li>
    <div class="frame">
      <div class="image"><img src="images/pic2.jpg" height="100" width="100"></div>
      <div class="greyscale"><img src="images/grey2.jpg" height="100" width="100"></div>
      <div class="effect">qewrt</div>
    </div>
  <开发者_JAVA技巧;/li> 
</ul>

</body>
</html>

would be super-awesome if someone can help me out :)


Try this:

.frame:hover .greyscale { display: none; }


Try adding this to you're css:

div.greyscale:hover img { display: none; }

This will hide you're image if you hover over the greyscale div.


Look into this example,

Here I have a big image on the top and 3 images below.

On mouse hover sll 3 images they will replace big one. on mouse out old image will come back

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title><br />

</head>

<body>
<p>
  <script type="text/javascript" language="javascript">
function changeImage(img){
   document.getElementById('bigImage').src=img;

}
</script>

  <img src="../Pictures/Bigcircle.png" alt="" width="284" height="156" id="bigImage" />
<p>&nbsp; </p>
<div>
  <p>
  <img src="../Pictures/lightcircle1.png" height=79 width=78 onmouseover="changeImage('../Pictures/lightcircle2.png')" onmouseout="changeImage('../Pictures/Bigcircle.png')"/>

 </p>
 <p><img src="../Pictures/lightcircle2.png" alt="" width="120" height="100" onmouseover="changeImage('../Pictures/lightcircle.png')" onmouseout="changeImage('../Pictures/Bigcircle.png')"/></p>

 <p><img src="../Pictures/lightcircle3.png" alt="" width="78" height="79" onmouseover="changeImage('../Pictures/lightcircle2.png')" onmouseout="changeImage('../Pictures/Bigcircle.png')"/></p>

 <p>&nbsp;</p>


  </br>
</div>
</body>
</html>

You cam modify it in the way you need it. Cheers..

0

精彩评论

暂无评论...
验证码 换一张
取 消