3 つの画像スライダーがあるページがあります。スライダーの左部分にカーソルを合わせると、左方向を示す矢印が表示され、マウスが置き換えられます。そして、スライダーの右部分にカーソルを合わせると、右方向を示す矢印が表示され、マウスが置き換えられます。また、これらの矢印はフェード インとフェード アウトを行ったり来たりします (そのため、css カーソル プロパティではなく jQuery を使用しています)。
私はそれをすべてやりましたが、問題は、マウスがスライダーを左から右下にのみ終了すると、マウスを別の方向に移動するまで矢印が消えないことです。
だからここに私のコードがあります.最初はHTML部分です:
<div id="arrow-prev" class="arrow">
<img id="cursorimg_prev" src="style/arrow-left.png" />
</div>
<div id="arrow-next" class="arrow">
<img id="cursorimg_next" src="style/arrow-right.png" />
</div>
CSS:
.arrow
{
height: 585px;
width: 750px;
position: absolute;
top: 0px;
}
#arrow-prev
{
left: 0px;
cursor: none;
width:50%;
}
#arrow-next
{
right: 0px;
cursor:none;
width:50%;
}
#cursorimg_prev,
#cursorimg_next
{
position: absolute;
display: none;
z-index: 99;
}
そしてjQueryの部分:
$('#arrow-prev').mousemove(function(event) {
var position = $('.slider_conteneur').position();
var x = event.pageX - position.left - 0;
var y = event.pageY - position.top - 0;
$('#cursorimg_prev').css({ top: y+"px", left: x+"px" });
});
$('#arrow-prev').hover(function() {
$('#cursorimg_prev').stop().fadeIn(100);
}, function(){
$('#cursorimg_prev').stop().fadeOut(100);
});
$('#arrow-next').mousemove(function(event) {
var position = $('.slider_conteneur').position();
var position2 = $('#arrow-next').position();
var x = event.pageX - position.left - position2.left;
var y = event.pageY - position.top - position2.top;
$('#cursorimg_next').css({ top: y+"px", left: x+"px" });
});
$('#arrow-next').hover(function() {
$('#cursorimg_next').stop().fadeIn(100);
}, function(){
$('#cursorimg_next').stop().fadeOut(100);
});
誰かが助けてくれることを願っています!