我想当悬停图像时,它会向下滚动到图像的末尾。
我有两个问题:
当用户将鼠标悬停在图像上时如何滚动到图像的末尾?目前,我开始将鼠标悬停在图像上,它没有滚动到图像的末尾。
如何控制鼠标悬停在图像上时滚动的速度?
My code:
body {
margin: 2px auto;
width: 500px;
}
.pic {
width: 48%;
height: 200px;
overflow: hidden;
margin: 0 auto;
display: inline-block;
position: relative;
cursor: pointer;
}
.pic:before {
width: 100%;
height: 200px;
background: rgba(0, 0, 0, 0.5);
position: absolute;
top: 0;
}
.pic:after {
color: #fff;
font-size: 18px;
position: absolute;
top: 50%;
left: 50%;
margin: -20px -25px;
border: 1px solid rgba(255, 255, 255, 0.5);
padding: 10px;
}
img {
max-width: 100%;
cusor: pointer;
}
.pic:hover img {
animation: moveSlideshow 3s linear;
}
@keyframes moveSlideshow {
100% {
transform: translateY(-60%);
}
}
.pic:hover .pic:after {
opacity: 0;
}
<div class="pic"><img src="http://scr.templatemonster.com/51600/51651-big.jpg" alt="" /></div>
<div class="pic"><img src="http://www.cssauthor.com/wp-content/uploads/2014/06/Good-to-Go-single-page-PSD-template1.jpg" alt="" /></div>
这很好用。我添加了一个计算,以便从图像的宽度减去 div 的高度,并且它仅滚动到 div 的底部。
CSS:
.pic:hover img {
animation: moveSlideshow 3s linear;
animation-fill-mode: forwards;
}
JSFiddle: here https://jsfiddle.net/Kai_Draord/58yxymLm/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)