【发布时间】:2014-06-05 21:04:19
【问题描述】:
我需要在悬停时在图像上显示标题文本,但只有图像会受到影响。它现在的工作方式是影响整个 div,包括图像下方的按钮。如何使悬停效果仅影响他的图像并保持按钮不变?
到目前为止,我已经尝试过在标题 div 周围洗牌,但没有运气。
由于图像是响应式的(不在此示例中),我无法为 fadeIn_capsFull 类定义确切的高度
有什么建议么?
看看这个FIDDLE
HTML
<div class="product-display fadeIn_caption">
<div class="fadeIn_capsFull">
<div class="capsFull_Text"><h5>PRODUCT ID12</h5><br>$225.00</div>
</div>
<a href="">
<img src="http://placehold.it/400x450" class="product-image" alt="">
</a>
<div class="product-addOptions">
<div class="product-toCart">Add to Cart</div>
<div class="product-toCompare">Add to Compare</div>
</div>
</div>
CSS
.fadeIn_capsFull {position:absolute; top:0; left:0; background:rgba(255, 255, 255, 0.75) ; width:420px; height:100%;display: table; display: none; text-align:center; color:#000 !important; z-index:2; cursor:pointer;}
.capsFull_Text { padding-top: 24%; text-align: center; }
.product-display { width:400px; min-height: 400px; padding: 10px; font-size: 13px}
.product-image {margin-bottom:10px; border-bottom: 1px solid #000;}
.product-addOptions { width: 100%; background-color: #0CF;}
.product-toCart { width: 50%; border-right: 1px solid #000; float:left; text-align:center; padding-top:5px; }
.product-toCompare {width: 49%; float:left; text-align:center; padding-top: 5px; }
jQuery
$("[rel='tooltip']").tooltip();
$('.fadeIn_caption').hover(
function(){
$(this).find('.fadeIn_capsFull').fadeIn(250)
},
function(){
$(this).find('.fadeIn_capsFull').fadeOut(205)
}
);
【问题讨论】:
-
您的看起来不正确。您可能希望将图像包装在 div 中并将鼠标悬停在其上。请填写你的 dom 应该放置的结束 div你是对的,一个关闭的 div 在复制粘贴中脱落了;ing问题现已更新,包括缺少结束 div