我有一张照片,上面有一些内容(名称、描述、价格),内容在 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();
}