css - 为什么悬停 div 元素在 iOS Safari (iPhone/iPad) 上不起作用?

标签 css hover mobile-safari

代码非常简单,请参阅下面的部分内容。 Full example here :

纯 HTML:

<div class="test1">
  <div class="silver1">
    <span>test1</span>
  </div>
    <span>box 1</span>
</div>

CSS

.test1 {
  border: 1px solid red;
  width: 80px;
  background-color: red;
}

.silver1 {
  width: 30px;
  height: 30px;
  position: relative;
}

.test1:hover .silver1 {
  top: 30px;
  left: 80px;
  border: 3px dotted blue;
  background-color: yellow;
}

测试:

  • 将鼠标悬停在 Windows 或 Windows 的任何流行浏览器中 麦克工作正常。
  • 通过点击 Android 手机上的方框即可工作 也是如此。
  • 在 Safari (iPhone/iPad) 上点击没有任何反应。
  • 按住 Safari 有时会起作用。

问题 如何激活 Safari iOS 的 :hover? 理想的纯 CSS 解决方案。

最佳答案

尝试在 :hover 之后放置 :active 。

https://codepen.io/mausinc/pen/LgvmXv

.test1:hover:active .silver1 {
  top: 30px;
  left: 80px;
  border: 3px dotted blue;
  background-color: yellow;
}

祝你好运

关于css - 为什么悬停 div 元素在 iOS Safari (iPhone/iPad) 上不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53049086/

相关文章:

html - 网页设计/CSS : Blurred text jitters when being "un-blurred" on hover

css - 鼠标悬停在图像上会更改文本链接颜色

javascript - 移动版 Safari 浏览器的滚动问题

javascript - html 内容中的 css 链接在加载 html 时抛出错误

CSS Transitions Twitter 的 Bootstrap 3

javascript - 如何使用 CSS/JavaScript 在链接上取消悬停?

ios - 在 iOS 设备上设置 native html5 日期和时间选择器的宽度

html - 有没有办法让一个 div 成为它父级以外的东西的高度?

jQuery CSS - 不要在 <a> 标签内选择 <img> 标签

ios - 移动 Safari Web App - 点击和手势 react 迟钝