【发布时间】:2014-06-25 07:09:28
【问题描述】:
我想在移动设备上启用触摸并携带相同的效果(或类似的东西),然后它是 HTML 元素上的悬停状态。
我有一个图像,在悬停时,应用了 transformX() 的 CSS3 过渡。我想用移动设备实现同样的效果,但只需向左滑动(或点击它)。
这可以通过 CSS3/HTML 实现吗?如果没有,你推荐使用哪个特定的 jQuery touch 库?
这是我的小提琴:http://jsfiddle.net/gT47d/12/
HTML
<a href="http://google.com" class="slide transform multi">
<img src="http://media02.hongkiat.com/fruits-vege-stock-photos/highres/orange-stock04.jpg" />
<div class="info">Fruit Info</div>
</a>
CSS
a.slide{
display: block;
position: relative;
padding: 0;
margin: 0;
}
.transform {
overflow:hidden;
}
.info{
color:#FFF;
font-family: arial;
position: absolute;
width: 100%;
padding: 10px;
top: 0px;
left: 0px;
background-color: rgba(0, 0, 0, 0.6);
}
.transform img {
position: relative;
z-index: 5;
width: 100%;
height: auto !important;
-webkit-transition: all 0.8s ease-in-out;
-moz-transition: all 0.8s ease-in-out;
-o-transition: all 0.8s ease-in-out;
-ms-transition: all 0.8s ease-in-out;
transition: all 0.8s ease-in-out;
}
.transform:hover img {
transform: translateX(90%);
opacity: .4;
}
.multi{
background: url(http://media02.hongkiat.com/fruits-vege-stock-photos/highres/fruitsvege-stock37.jpg);
background-size:cover;
}
【问题讨论】: