0

ヘッダーにカーソルを合わせたときにも画像の不透明度を変更する必要があります。これで、画像にカーソルを合わせたときにのみ不透明になります。

ここでフィドル スクリプトの例を参照してください: http://jsfiddle.net/fourroses666/EmsaG/1/

JS:

$(document).ready(function(){    
  $("img.a").hover(
    function() {
      $(this).stop().animate({"opacity": "0"}, "slow");
    },
    function() {
      $(this).stop().animate({"opacity": "1"}, "slow");
  }); 
});

HTML:

<div class="m-blok one">
    <h3 class="m-kop"><a href="#">Some header</a></h3>
    <img class="a" src="http://tinyurl.com/732qwvt" width="178" height="78" alt="" style="opacity: 1;">
    <img class="b" src="http://tinyurl.com/nrbj2uk" width="178" height="78" alt="" />
</div>

CSS

.m-blok{width:178px; height:78px; position:relative; margin:15px;}

img.a {left: 0; position: absolute; top: 0; z-index: 10;}
img.b {left: 0; position: absolute; top: 0;}

.m-kop{position:absolute; z-index:11; color:#fff; margin:55px 0 0 5px; max-width:150px; background:#f00;}
.m-kop a, .m-kop a:hover{color:#fff; text-decoration:none;}
4

1 に答える 1

1

すでに行ったことを使用すると、次のように実行できます。

$(document).ready(function(){    
  $("img.a, .m-kop").hover(
    function() {
      $("img.a").stop().animate({"opacity": "0"}, "slow");
    },
    function() {
      $("img.a").stop().animate({"opacity": "1"}, "slow");
  }); 
});
于 2013-10-22T12:47:27.137 に答える