我正在做一个网站项目,我想有这个很酷的悬停效果,但我似乎无法让它正常工作?
我有一个黑胶唱片案例图片向左滑动并带有标题(溢出:隐藏)以显示其背后的记录图像。同时从左边开始,我希望记录的描述从左侧移动到左边的记录图像中滑出,并且在记录图像的顶部稍微不透明,这样你仍然可以看到记录(这一部分)很容易)
这是html代码:
<div id="stations">
<div class="grid_3">
<div class="records"><!-- sleeve -->
<h3>Groove Salad</h3>
<div class="recordsinfo">Station description.</div>
</div>
</div>
</div>
这是css代码:
#stations>div {
background-image: url(http://benlevywebdesign.com/somafm/images/SomaFMrecord.png);
background-repeat:no-repeat;
height: 220px;
margin-bottom: 20px;
position: relative;
overflow:hidden;
}
#stations>div>.records{
background-image: url(http://benlevywebdesign.com/somafm/images/SomaFM.png);
background-repeat:no-repeat;
height: 220px;
margin-bottom: 20px;
overflow:hidden;
position:relative;
}
#stations>div>.records>h3 {
color: #FFF;
background-color: rgba(255,255,255, 0.45);
width:200px;
margin-top:0px;
margin-bottom:-5px;
padding: 10px 10px 3px;
}
#stations>div>.records>.recordsinfo{
position: absolute;
left:-150px;
bottom: 0;
margin: 5px 10px;
}
@-moz-keyframes slideout {
0% { left:0; }
100% { left:-100px; }
}
@-webkit-keyframes slideout {
0% { left:0; }
100% { left:-100px; }
}
@keyframes slideout {
0% { left:0; }
100% { left:-100px; }
}
#stations>div>.records:hover{
height: 220px;
width:220%;
margin-bottom: 20px;
left:-100px;
overflow:hidden;
position: relative;
-moz-animation: slideout 0.75s 1;
-webkit-animation: slideout 0.75s 1;
animation: slideout 0.75s 1;
}
#stations>div>.records>.recordsinfo:hover{
height: 220px;
width:220%;
left:150px;
overflow:hidden;
position: relative;
-moz-animation: slidein 0.75s 1;
-webkit-animation: slidein 0.75s 1;
animation: slidein 0.75s 1;
}
这是一个小提琴,直到最后一部分,说明不起作用,向左滑出!
答案 0 :(得分:1)
试试这个 - DEMO
的 HTML 强> 的
<div id="stations">
<div class="grid_3">
<div class="records"><!-- sleeve -->
<h3>Groove Salad</h3>
</div>
<div class="recordsinfo">Station description.</div>
</div>
</div>
的 CSS 强> 的
#stations > div {
background-image: url(http://benlevywebdesign.com/somafm/images/SomaFMrecord.png);
background-repeat:no-repeat;
height: 220px;
margin-bottom: 20px;
position: relative;
overflow:hidden;
}
#stations > div:hover .records {
margin-left: -110px;
}
#stations .records{
background-image: url(http://benlevywebdesign.com/somafm/images/SomaFM.png);
background-repeat:no-repeat;
height: 220px;
margin: 0 0 20px 0;
overflow:hidden;
position:relative;
-webkit-transition: all .75s;
-moz-transition: all .75s;
transition: all .75s;
}
#stations h3 {
color: #FFF;
background-color: rgba(255,255,255, 0.45);
width:200px;
margin-top:0px;
margin-bottom:-5px;
padding: 10px 10px 3px;
}
#stations > div:hover .recordsinfo {
margin-left: 0;
}
#stations .recordsinfo {
background: rgba(0, 0, 0, .8);
color: #fff;
position: absolute;
width: 150px;
bottom: 0;
margin: 5px 10px 5px -150px;
-webkit-transition: all .75s;
-moz-transition: all .75s;
transition: all .75s;
}
答案 1 :(得分:0)
如果我理解得很好,你希望标题保持原样吗?如果是这样,你去吧:
#stations > div > .records:hover h3 {
margin-left: 100px;
}
答案 2 :(得分:0)
最后!你有很多不同的问题,从设置220%的宽度,而不是px,到试图动画动画的子项(所以它的位置关闭),没有定义你想要使用的幻灯片动画。
试试这个:jsFiddle