html - Css3 过渡不适用于 ios

标签 html ios css

在 PC 和 Android 设备上我的转换代码可以工作,但在 iOS 设备上它不会工作。我只使用 html 和 css。

/***** BOX 3 *****/
#box3 {
height:240px;
width:198px;
border:1px solid #dedede;
background-color:#fcfcfc;
position:relative;
overflow:hidden;
float:left;
margin-right:23px;
margin-bottom:23px;
opacity:1;
-webkit-transition: opacity .2s ease-out;
-moz-transition: opacity .2s ease-out;
-o-transition: opacity .2s ease-out;
-ms-transition: opacity .2s ease-out;
transition: opacity .2s ease-out;
}

#box3:hover {
-webkit-box-shadow: 0 0 3px #999;
-moz-box-shadow: 0 0 3px #999;
box-shadow: 0 0 3px #999;
}

#box3 .bgbox3 {
background:url(images/top-seller-3.jpg) 50% 10% no-repeat;
position:absolute;
height:240px;
width:198px;
opacity:1;
-webkit-transition: all .2s ease-out-in;
-moz-transition: all .2s ease-in-out;
-o-transition: all .2s ease-in-out;
-ms-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
}

#box3:hover .bgbox3 {
opacity:0.3;
}

#box3 a, #box3 a:hover {
text-decoration: none;
}

.imagebox3 {
background: url(images/bestellen.jpg);
background-repeat:no-repeat;
position:absolute;
height:40px;
width:40px;
opacity:0;
margin-top:80px;
margin-left:10px;
-webkit-transition: all .2s linear;
-moz-transition: all .2s linear;
-o-transition: all .2s linear;
-ms-transition: all .2s linear;
transition: all .2s linear;
}

#box3:hover .imagebox3 {
opacity:1;
-webkit-transform:translate(45px ,0);
transform:translate(45px ,0);
}

非常感谢 问候帖木儿

最佳答案

要快速修复,请尝试使用 :active选择器以及 :focus

最可靠的方法是将这些属性放入并去掉 CSS 部分:

<div id="box3" ontouchstart="this.setAttribute('style','-webkit-box-shadow:0 0 3px #999;')" ontouchend="this.setAttribute('style','')">

Ontouchstartonmousedown的官方iOS/Android/webkit版本.它实际上会在有人触摸屏幕时立即触发,而鼠标事件具有长按检测延迟。

另一件事,你可以设置 this.style.boxShadow直接代替,但根据经验,阴影不喜欢以编程方式设置时呈现,因此从头开始设置属性会强制重新绘制。

希望这对您有所帮助!

关于html - Css3 过渡不适用于 ios,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30536611/

相关文章:

html - 如何更改调整大小的样式?

javascript - 错误 404 找不到 js 文件

ios - UIView alpha 值问题

asp.net - @fontface 不起作用

html - 防止侧边栏下推内容,在小屏幕上放在中间

javascript - 为 Canvas 形状创建鼠标事件处理程序

php - 将简单的 HTML 表解析为 php 数组的 Xpath 循环问题

ios - ARKit 和 Reality Composer - 如何使用图像坐标锚定场景

ios - 使用 OutputStream 写入时如何检查是否成功?

css - 如何创建此逐步形状以展示流程