问题
i have following code
<div>
<img src="http://placehold.it/350x150"/>
<div class="link-cont"><a href="#">click here to see more info</a></div>
</div>
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;
}
A link is wrapped inside a div which appears on hover. how do i make this touch device friendly.
jsfidd--> http://jsfiddle.net/yeyene/Nnd7w/17/
回答1:
Several solutions:
- skip hover effects in touch device stylesheets
- use JavaScript to turn hover into click interactions
- use JavaScript to simulate hover interactions on the touch device (see this Question on StackOverflow
回答2:
Try this:
<script>
document.addEventListener("touchstart", function(){}, true);
</script>
来源:https://stackoverflow.com/questions/17259848/how-to-deal-with-hover-effect-on-touch-devices