1

私はお互いの上に3つの画像を持っています。最初の 1 つは通常の .jpg 画像、2 番目はグレースケール バージョン、3 番目は透明な .png で追加するある種の効果です。

今私が欲しいのは、これらの画像の上にマウスを移動すると、グレースケール画像が非表示になるか、別の画像に置き換えられ、その後再び表示されることです。

ここでの問題は、私が js 初心者なので、解決策を見つけるのが難しいことです ^^

私のコードは次のようになります。

<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>
  </li> 
</ul>

</body>
</html>

誰かが私を助けることができれば、とても素晴らしいでしょう:)

4

3 に答える 3

3

これを試して:

.frame:hover .greyscale { display: none; }
于 2010-04-18T00:01:02.953 に答える
1

この例を見て、

ここでは、上に大きな画像があり、下に 3 つの画像があります。

マウスを sll 3 つの画像に合わせると、大きな画像が置き換えられます。マウスアウトすると古い画像が戻ってきます

<!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>

必要な方法で変更できます。乾杯..

于 2012-03-05T12:03:18.037 に答える
1

これをcssに追加してみてください:

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

グレースケールの div にカーソルを合わせると、画像が非表示になります。

于 2010-04-17T22:13:27.427 に答える