ここで見つけたjqueryツールチッププラグインを使用して、ホバー効果ロールオーバーを使用しているサムネイル画像の小さな行があります: http://cssglobe.com/easiest-tooltip-and-image-preview-using-jquery。
プラグインはデフォルトで正常に動作しますが、プレビュー画像の配置をうまく制御できません。(具体的には、プレビューをサムネイルの左上に表示する)
ほとんどの画像はページの右側にあるため、サムネイルの左上にプレビューを表示する必要があります。javascript で y または x オフセット変数を調整すると、カーソルとプレビュー画像がループのように点滅し始めます。
CSSは次のとおりです。
<style>
#screenshot{
position:absolute;
border:1px solid #ccc;
background:#333;
padding:5px;
display:none;
color:#fff;
}
</style>
Javascript は次のとおりです。
this.screenshotPreview = function(){
/* CONFIG */
xOffset = 10;
yOffset = 30;
// these 2 variable determine popup's distance from the cursor
// you might want to adjust to get the right result
/* END CONFIG */
$("a.screenshot").hover(function(e){
this.t = this.title;
this.title = "";
var c = (this.t != "") ? "<br/>" + this.t : "";
$("body").append("<p id='screenshot'><img src='"+ this.rel +"' alt='url preview' />"+ c +"</p>");
$("#screenshot")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px")
.fadeIn("fast");
},
function(){
this.title = this.t;
$("#screenshot").remove();
});
$("a.screenshot").mousemove(function(e){
$("#screenshot")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px");
});
};
// starting the script on page load
$(document).ready(function(){
screenshotPreview();
});
ここに私のHTMLがあります:
<a href="#" class="screenshot" rel="/images_no/products_large/img_10.png" title="Available Drawer Knob Options"><img src="/images_no/products_small/img_10.png" border="0"></a>