その上にいくつかのコンテンツ(名前、説明、価格)が含まれている写真があります。コンテンツはulにあります。デフォルトの状態では、ulは、画像の下部に向かってulの絶対位置を設定し、マスクdivでオーバーフローを非表示にすることによってのみ名前を表示します。次に、マウスオーバーすると、画像上に留まっている限り、ulが上にスライドして情報全体が表示されます。マウスアウトすると、タイトルが表示されているだけで元の位置にスライドして戻ります...これが機能するはずです。現在、マウスにカーソルを合わせると、マウスは上下左右にスライドします。
これがhtmlとスタイルです
div.banner_product {
float: left; width: 236px; position: relative; overflow: visible;
}
div.banner_product ul {
width: 220px;
background-color: black;
font-size: 16px;
color: white;
list-style-type: none;
position: absolute; top: 230px;
margin: 8px;
filter: alpha(opacity=70); /* internet explorer */
-khtml-opacity: 0.7; /* khtml, old safari */
-moz-opacity: 0.7; /* mozilla, netscape */
opacity: 0.7; /* fx, safari, opera */
}
.mask {
position: absolute;
top: 0;
overflow: hidden;
height: 300px;
width: 235px;
}
/*html*/
<div class="banner_product" id="pi1"><img src="image1.jpg" alt="" border="0" height="306" width="235" /><div class="mask">
<ul id="bd1">
<li class="name-b"><a href="#">PRODUCT NAME</a></li>
<li class="text-b">DESCRIPTION</li>
<li class="price-b">PRICE</li>
</ul></div>
</div>
これはスクリプトです:
$('#pi1')
.bind('mouseover',enterImg)
.bind('mouseout',exitImg)
function enterImg(event){
$('#bd1').animate({"top": "4px"}, 2000);
event.stopPropagation();
}
function exitImg(event){
$('#bd1').animate({"top": "236px"}, 2000);
event.stopPropagation();
}