我希望图像覆盖(与文本)只显示时,div是悬空的。默认情况下隐藏。如果合适的话由JavaScript。
我尝试复制css,给出第一个(显示:无)和第二个(悬停和不显示),但是没有工作,所以尝试使用JavaScript添加/删除(display: none)类。
我已经包括了一个实时网址。我收到了6个主页的图片。


Live:http://bit.ly/1jl1QaT
HTML
<div class="desc"><p><?=((strlen($r_main['friendlyTitle'])>40)?substr($r_main['friendlyTitle'],0,40).'...':$r_main['friendlyTitle']);?></p></div>
</div></a>
<a href="Shopping/"><div class="feature-2">
<div class="header"><p>Shopping</p></div>
<div class="desc"><p>Grab yourself a pair of Mink Fur Eyelashes for only £19.95 </p></div>
</div></a>CSS
#content-mid .col-2 .features .feature-1 .desc, #content-mid .col-2 .features .feature-2 .desc, #content-mid .col-2 .features .feature-3 .desc, #content-mid .col-2 .features .feature-4 .desc, #content-mid .col-2 .features .feature-5 .desc, #content-mid .col-2 .features .feature-6 .desc { position:absolute; width: 220px; height: 50px zoom: 1; filter: alpha(opacity=90); opacity: 0.9; background: #333; bottom: 0; margin-bottom: 5px; display: none; }
#content-mid .col-2 .features .feature-1 .desc, #content-mid .col-2 .features .feature-2 .desc, #content-mid .col-2 .features .feature-3 .desc, #content-mid .col-2 .features .feature-4 .desc, #content-mid .col-2 .features .feature-5 .desc, #content-mid .col-2 .features .feature-6 .desc-show { position:absolute; width: 220px; height: 50px zoom: 1; filter: alpha(opacity=90); opacity: 0.9; background: #333; bottom: 0; margin-bottom: 5px; }JavaScript
$(".desc").hover(
function () {
$(this).removeClass("desc-show");
},
function () {
$(this).addClass("desc");
}
);发布于 2013-12-19 11:25:40
HTML
<div style="background-color:red;">
<div id="blah">DEMO TEXT ON MOUSE OVER</div>
</div>JAVA脚本
$('#blah').hover(function() {
$(this).fadeTo(1,1);
},function() {
$(this).fadeTo(1,0);
});CSS
#blah {
width:100px;
height:100px;
background-color:green;
visibility: visible;
opacity:0;
filter:alpha(opacity=0);
}琴杆
发布于 2013-12-19 12:03:38
#content-mid .col-2 .features .feature-1{
border: 1px solid #E5E5E5;
float: left;
height: 160px;
overflow: hidden;
padding: 5px;
position: relative;
width: 220px;
z-index:-1;
}
#content-mid .col-2 .features .image_holder_home_page{
height: 160px;
overflow: hidden;
position: relative;
width: 220px;
}
#content-mid .col-2 .features .feature-1 .header{
background: none repeat scroll 0 0 #0098FF;
height: 30px;
position: absolute;
width: 95.5%;
}请将上述css代码添加到您的站点中。因为有些潜水元素已经溢出了。这将解决这个问题。
发布于 2013-12-19 11:29:33
试试这把小提琴。我已经用了很多次了。
$(document).ready(function () {
$(document).on('mouseenter', '.divbutton', function () {
$(this).find(":button").show();
}).on('mouseleave', '.divbutton', function () {
$(this).find(":button").hide();
});
});只需编辑这段代码,把你的div,而不是按钮。
https://stackoverflow.com/questions/20680431
复制相似问题