html - 图像悬停效果问题

标签 html css css-transitions

您好,我正在尝试在 img 上创建悬停效果。

HTML

<div>
    <img src="http://placehold.it/350x150"/>
    <div class="link-cont"><a href="#">click here to see more info</a></div>

</div>

CSS

div {
    width: 350px;
position: relative;    
}
.link-cont {
    background: red;
    position: absolute;
    bottom: 0;
    height: 100px; 
    opacity: 0;
    transition: all 0.4s;
}
div:hover  .link-cont {
    opacity: 1; 
    bottom:-100px;
}

我需要这样的东西,当用户悬停在它上面时 image

但是我得到了这样的东西

current

有人能帮我实现我想做的事吗..

jsFid--> http://jsfiddle.net/Nnd7w/

最佳答案

你想要这样,查看DEMO http://jsfiddle.net/yeyene/Nnd7w/17/

div {
    width: 350px;
    font-size:12px;
    position: relative;    
}
div img{
    padding:0 10px;    
}
.link-cont {
    background: red;
    position: absolute;
    bottom: 0;
    width: 370px;
    height: 210px; 
    opacity: 0;
    transition: all 0.4s;
    z-index: -1
}
div:hover  .link-cont {
    opacity: 1; 
    bottom:-40px;
}
.link-cont a{    
    opacity: 0;  
}
div:hover  .link-cont a{
    position: relative; 
    opacity: 1; 
    bottom:-175px;
    left:10px;
    background:#fff;
    color:red;
    text-decoration:none;
    padding:0 10px;
}

关于html - 图像悬停效果问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17258105/

相关文章:

javascript - 复选框顺序不正确

java - Struts 2转义html不起作用?

html - 如何在 CSS 中对齐元素

javascript - 从 JS 以编程方式使用 CSS 转换的简洁方法?

jquery - 使用 jQuery css 显示 -webkit-transition

javascript - 滚动事件关闭菜单后,导航下拉菜单切换不显示菜单

html - Internet Explorer 无法识别字体

javascript - 如何触发布局改变?

html - 如何使 div 容器响应?

AngularJS ng-class 无法覆盖 Bootstrap 下拉 CSS 规则