私には2つdivs
あります。ホバーspan class=fg
すると、不透明度が大きくなり、不透明度が変わり、span class=bg
縮小しmouseout
ます。元の状態に戻ると、
私の問題は2つの部分にあります:
1:最初のdivにカーソルを合わせると、2番目のdivでも同じアクションが発生します。
2:ホバーはdivに制限されませんが、マウスがページ上を移動するたびに発生します。
HTML:
<div id="wrap">
<h2>Subtitle</h2>
<p>
<span class="bg">Lorem Ipsum has been the</span>
<a href="#"><span class="fg"> industry’s standard</span></a>
<span class="bg">dummy text ever</span>
<span class="fg">since the 1500s,</span>
span class="bg">when an unknown printer took a galley of type and</span>
</p>
</div>
<div id="wrap" class="">
<h2>Stuff #2</h2>
<p>
<span class="bg">Lorem Ipsum has been the</span>
<span class="fg"> industry’s standard</span>
<span class="bg">dummy text ever</span>
<span class="fg">since the 1500s,</span>
<span class="bg">when an unknown printer took a galley of type</span>
</p>
</div>
javaScript:
<script type="text/javascript">
$(document).ready(function() {
$("#wrap").parent().hover (function () {
$("span.fg").animate({"opacity": 1, fontSize: '14px'}, 300);
$("span.bg").animate({fontSize: '7px'}, 300);
},
function () {
$("span.fg").animate({"opacity": .5, fontSize: '12px'}, 100);
$("span.bg").animate({fontSize: '12px'}, 100);}
);
});
CSS:
body {background: #000;color: #FFF;font-family: Helvetica, sans-serif;}
p {font-size:12px;}
#wrap { width: 300px;
height: 150px;
cursor: pointer;
margin: 30px auto;
overflow:hidden;
}
a {text-decoration:none; color:inherit;}
.bg {color:#999; opacity: 0.4;}
.fg {color:#999; opacity: 0.4;}