[英]Flip animation not working on safari
我的網站上有一個翻轉動畫。 它適用於PC和Android上的每種瀏覽器,但不適用於Safari。 它會翻轉,您會看到“后”卡的閃爍,然后消失,您只會得到一個白色方塊。 我想我設置了-webkit-
就像應該設置的一樣,但是由於某種原因它無法正常工作。 有人有什么想法嗎?
HTML:
<div class="card">
<div class="face front hover">
<img src="images/pawprints_edit.png" width="300" height="180" alt="sign up for al-van newsletter" id="news-img" class="d-inline-block col-md-12 img-fluid my-5 pt-2" />
<p id="thanks" class="text-center"></p>
</div>
<div class="face back">
<form name="mailForm" class="mail-form" autocomplete="on" novalidate>
<div class="form-group mb-0 px-2">
<label for="name">Name:</label>
<input type="text" class="form-control form-control-sm" id="name" placeholder="John Doe">
</div>
<div class="form-group mb-0 px-2">
<label for="email">Email Address:</label>
<input type="text" class="form-control form-control-sm" id="email" placeholder="yourname@domain.com">
</div>
<div class="form-group mb-0 px-2">
<label for="message">Please type your message:</label>
<textarea class="form-control form-control-sm" id="message" cols="30" rows="4"></textarea>
<input type="button" id="submit" value="Submit">
<input type="button" id="cancel" value="Cancel">
<p id="errorP" class="text-center"></p>
</div>
</form>
</div>
</div>
CSS:
/* form animation */
.scene {
width: 100%;
height: 300px!important;
perspective: 1000px;
-webkit-perspective: 1000px;
border: none;
}
.card {
width: 100%;
height: 100%;
position: relative;
-webkit-transition: -webkit-transform 1s;
transition: transform 1s;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
border: none;
}
.face {
position: absolute;
height: 100%;
width: 100%;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.front {
background: #98b98a;;
-webkit-z-index: -1;
z-index: -1
}
.front.hover {
background: #98b98a;
-webkit-z-index: 2;
z-index: 2;
}
.back {
background: #4c87a9;
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
-webkit-z-index: 1;
z-index: 1;
}
.back [type=text]:hover {
cursor: text!important;
}
.card.is-flipped {
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.hover:hover {
cursor: pointer;
}
/* End animation */
和JS:
/* flip animation script */
function flip()
{
'use strict';
console.log("Flip is being triggered");
var card = document.querySelector(".card");
var face = document.querySelector(".front");
var name = document.getElementById("name");
var email = document.getElementById("email");
var errorP = document.getElementById("errorP");
if(card.removeEventListener)
{card.removeEventListener("click", flip, false);}
else if(card.detachEvent)
{card.detachEvent("onclick", flip);}
card.classList.toggle("is-flipped");
face.classList.toggle("hover");
name.style.background = "#fff";
email.style.background = "#fff";
errorP.style.display = "none";
}
/* Function to flip the card back over when canceled */
function cancelFlip()
{
'use strict';
console.log("Cancel has been activated");
var card = document.querySelector(".card");
var face = document.querySelector(".front");
card.classList.toggle("is-flipped");
face.classList.toggle("hover");
setTimeout(function(){if(card.addEventListener){card.addEventListener("click",flip,false);}else if(card.attachEvent){card.attachEvent("onclick",flip);}console.log("setTimeout was triggered");}, 500);
}
我正在使用Boostrap 3框架。 JS是自定義的,而CSS則來自在線教程。 該網站的鏈接為: http : //www.al-van.org/jake我正在Windows平台上進行開發,沒有iPhone可以測試,所以我讓繼父在他的電腦上對其進行檢查當我進行iPhone更改時。 到目前為止,沒有任何工作。
更新:好像表單在那里,我能夠單擊內容並輸入文本,但實際上看不到任何內容。 它顯示為白色正方形,看不到任何內容。 我將背面可見性從.face移至每個.front和.back,以查看是否有區別。 似乎沒有。
在類-.card.is-flip中添加背面可見性,因為您也在該類上使用了transform
我發現了問題。 似乎.card
類具有默認的背景顏色,該顏色會使整個表單.card
白色,並且在翻轉時會洗掉其所有組件。 當我刪除此默認背景色並將其設為透明時。 問題已解決。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.