繁体   English   中英

CSS3过渡不适用于iOS

[英]Css3 Transition dont work on ios

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

非常感谢Timur

要快速修复,请尝试将: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 ,但是根据经验,以编程方式设置时阴影不喜欢渲染,因此从头开始设置属性会强制重新绘制。

希望这可以帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM