CSS:悬停在iOS Safari和Chrome上不起作用 [英] CSS :hover not working on iOS Safari and Chrome

查看:149
本文介绍了CSS:悬停在iOS Safari和Chrome上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个圆形的div,它有一个圆形的图像和一个标题在不透明度:0.5; 悬停时,不透明度应该变成1.它对所有桌面浏览器和适用于iOS的Firefox,但它不适用于iOS的Safari和Chrome。

I have a rounded div which has a rounded image and a title at the bottom whith opacity: 0.5; On hover the opacity should become 1. It forks fine on all desktop browsers and Firefox for iOS but it doesn't work on Safari nor Chrome for iOS.

小提琴: https://jsfiddle.net/a10rLbnL/2/

HTML:

<div class="video_wrap update">
  <div class="content">
    <div class="img_wrap"><img src="https://i.ytimg.com/vi/0HDdjwpPM3Y/hqdefault.jpg"></div>
    <div class="title_wrap"><div class="title">bang bang</div></div>
  </div>
</div>

CSS:

CSS:

.video_wrap {
    display: inline-block;
    width: 30%;
    padding-bottom: 30%;
    margin: 0 1%;
    position: relative;
    vertical-align: top;
}

.content {
    position: absolute;
    height: 100%;
    width: 100%;
}

.img_wrap {
    height: 100%;
    border-radius: 120px;
    overflow: hidden;
}

.title_wrap {
    line-height: 50px;
    top: -50px;
    height: 50px;
    position: relative;
    left: 0px;
    background: #fff;
    color: #f8008c;
    font-size: 12px;
    text-align: center;
    cursor: default;
    opacity: 0.5;
    transition: all .5s ease-in;
    min-height: 50px;
}

.img_wrap img {
    height: 100%;
    cursor: pointer;
}

.title_wrap:hover {opacity: 1}


推荐答案

我找到了一个解决方法:如果您向div中添加 onclick =,悬停会起作用。

I found a workaround: if you add onclick="" to the div, the hover will work.

您的html会是:

Your html would be:

<link rel="stylesheet" href="hover.css" type="text/css"/>

<div class="video_wrap update">
  <div class="content">
    <div class="img_wrap"><img src="https://i.ytimg.com/vi/0HDdjwpPM3Y/hqdefault.jpg"></div>
    <div class="title_wrap" onclick=""><div class="title">bang bang</div></div>
  </div>
</div>

这篇关于CSS:悬停在iOS Safari和Chrome上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆