【发布时间】:2012-01-15 05:15:41
【问题描述】:
我正在使用以下代码。
通过点击divid="popUpPane",div 和它的孩子应该会出现并慢慢淡入。
再次点击 div,它应该会慢慢淡出然后消失。
Firefox 和 Chrome(也是 webkit)的行为方式是这样的,我知道 Safari 在早期版本中也是如此。但是在 Safari 和 Safari Mobile 上,当我点击“popUpPane”时,什么都没有发生。
这是 Safari 中的错误,还是我可以更改某些内容以恢复预期的行为?
一个补充:如果我将-webkit-transition 设置为-webkit-transition: opacity .5s ease-in-out; 它工作正常,但过渡只出现在第一次点击。在第一个之后没有过渡...如果我删除 java-script 中的opacity-part,则 opo-up 可以工作,但没有过渡。
我网站上的所有其他转换都正常工作。但他们都只使用opacity,没有使用visibility。
这是我的代码:
CSS:
#popUpPane {
white-space:normal;
position:fixed;
width:100%;
height:100%;
top:0;
left:0;
text-align:center;
vertical-align:middle;
visibility:hidden;
z-index:90;
}
#greyOut {
position:fixed;
width:100%;
height:100%;
top:0;
left:0;
background-color:#000;
opacity:0;
}
#popUpPicCanvas {
position:relative;
top:50%;
margin-top:-325px;
display:inline;
opacity:0;
z-index:100;
}
.fade {
-webkit-transition: all .5s ease-in-out;
-moz-transition: all .5s ease-in-out;
-o-transition: all .5s ease-in-out;
transition: all .5s ease-in-out;
}
HTML:
<div id="popUpPane" onClick="noPopUp()">
<div id="greyOut" class="fade"> </div>
<canvas id="popUpPicCanvas" width="1000" height="650" title="Bastian Beuttel" class="fade"></canvas>
</div>
Javascript:
var popUpPane = document.getElementById("popUpPane"),
greyOut = document.getElementById("greyOut"),
popUpPicCanvas = document.getElementById("popUpPicCanvas"),
popCanvasContext = popUpPicCanvas.getContext("2d");
var doPopUp = function(source,x,y){
var popUpPic = document.getElementById("pic"+source);
popCanvasContext.canvas.width = x;
popCanvasContext.canvas.height = y;
popCanvasContext.drawImage(popUpPic, 0, 0,x,y);
popUpPane.style.visibility = "visible";
greyOut.style.opacity = "0.7";
popUpPicCanvas.style.opacity = "1";
};
var noPopUp = function(){
greyOut.style.opacity = "0";
popUpPicCanvas.style.opacity = "0";
popUpPane.style.visibility = "hidden";
};
我希望有人可以帮助我。
感谢您的回复!
【问题讨论】:
标签: javascript css safari visibility css-transitions