【问题标题】:how to deal with hover effect on touch devices如何处理触摸设备上的悬停效果
【发布时间】:2013-06-23 19:42:01
【问题描述】:

我有以下代码

<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;
}

一个链接被包裹在一个 div 中,该 div 出现在悬停时。我如何使这个触摸设备友好。

jsfidd--> http://jsfiddle.net/yeyene/Nnd7w/17/

【问题讨论】:

    标签: html css touch responsive-design


    【解决方案1】:

    几种解决方案:

    • 跳过触摸设备样式表中的悬停效果
    • 使用 JavaScript 将悬停变成点击交互
    • 使用 JavaScript 在触摸设备上模拟悬停交互(请参阅this Question on StackOverflow

    【讨论】:

      【解决方案2】:

      试试这个:

      <script>
      document.addEventListener("touchstart", function(){}, true);
      </script>
      

      【讨论】:

        猜你喜欢
        • 2017-07-02
        • 2012-02-16
        • 1970-01-01
        • 1970-01-01
        • 2013-10-22
        • 2013-06-18
        • 2023-04-07
        • 1970-01-01
        相关资源
        最近更新 更多