在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);
}
非常感谢 关心帖木儿
答案 0 :(得分:0)
要快速解决问题,请尝试使用:active
选择器和:focus
?
最可靠的方法是将这些属性放入并删除CSS部分:
<div id="box3" ontouchstart="this.setAttribute('style','-webkit-box-shadow:0 0 3px #999;')" ontouchend="this.setAttribute('style','')">
Ontouchstart
是onmousedown
的官方iOS / Android / webkit版本。它实际上是在有人触摸屏幕的瞬间触发,而鼠标事件则有长时间检测延迟。
另外,你可以直接设置this.style.boxShadow
,但是根据经验,阴影不喜欢以编程方式设置渲染,因此从头开始设置属性会强制重新绘制。
希望这有帮助!