2015-01-02 87 views
2

我正在嘗試在Internet Explorer 11中使用CSS翻轉卡。我已閱讀其他問題,解決方案是爲翻轉卡功能添加'-ms'前綴。我已經做到了這一點,但在IE 11中,由於某些原因翻轉卡不顯示背面。CSS翻轉卡Internet Explorer問題

http://jsbin.com/hazejuzezu/1/edit?html,css,js,output

任何幫助極大的讚賞。

HTML代碼

<div class="flip y-theme-icon-wrapper"> 
    <div class="card text-center"> 
     <div class="face front"> 
      <div class="y-theme-icon"> 
       <img src="http://i.kinja-img.com/gawker-media/image/upload/s--4bKbxQOb--/1036281511469286726.jpg" height="90" alt=""> 
      </div> 
     </div> 
     <div class="face back"> 
      <br><p>More information about this subject.</p> 
     </div> 
    </div> 
</div> 

CSS代碼:

.y-theme-icon-wrapper{ 
    width: 140px; 
    height: 140px; 
} 
.y-theme-icon { 
    display: block; 
    width: 140px; 
    height: 140px; 
    background: @color-1; 
    border-radius: 70px; 
    -webkit-border-radius: 70px; 
    -moz-border-radius: 70px; 
    -o-border-radius: 70px; 
    text-align:center; 
} 
.flip .card .back{ 
    background-color: #fff; 
} 
.flip { 
    -webkit-perspective: 800; 
    -ms-perspective: 800; 
    -moz-perspective: 800; 
    -o-perspective: 800; 
    position: relative; 
    margin: 12px auto; 
    height: 100px; 
    z-index: 1; 
    position: relative; 
} 
.flip .card.flipped { 
    transform:rotatey(-180deg); 
    -ms-transform:rotatey(-180deg); /* IE 9 */ 
    -moz-transform:rotatey(-180deg); /* Firefox */ 
    -webkit-transform:rotatey(-180deg); /* Safari and Chrome */ 
    -o-transform:rotatey(-180deg); /* Opera */ 
} 
.flip .card { 
    -webkit-transform-style: preserve-3d; 
    -webkit-transition: 0.5s; 
    -moz-transform-style: preserve-3d; 
    -moz-transition: 0.5s; 
    -ms-transform-style: preserve-3d; 
    -ms-transition: 0.5s; 
    -o-transform-style: preserve-3d; 
    -o-transition: 0.5s; 
    transform-style: preserve-3d; 
    transition: 0.5s; 
} 
.flip .card .face { 
    position: absolute; 
    z-index: 2; 
    text-align: center; 
    backface-visibility: hidden; /* W3C */ 
    -webkit-backface-visibility: hidden; /* Safari & Chrome */ 
    -moz-backface-visibility: hidden; /* Firefox */ 
    -ms-backface-visibility: hidden; /* Internet Explorer */ 
    -o-backface-visibility: hidden; /* Opera */ 
} 
.flip .card .front { 
    position: absolute; 
    z-index: 1; 
    cursor: pointer; 
} 
.flip .card .back { 
    color: black; 
    cursor: pointer; 
    transform:rotatey(-180deg); 
    -ms-transform:rotatey(-180deg); /* IE 9 */ 
    -moz-transform:rotatey(-180deg); /* Firefox */ 
    -webkit-transform:rotatey(-180deg); /* Safari and Chrome */ 
    -o-transform:rotatey(-180deg); /* Opera */ 
} 

/* Postcard */ 
.postcard-flip { 
    -webkit-perspective: 800; 
    -ms-perspective: 800; 
    -moz-perspective: 800; 
    -o-perspective: 800; 
    position: relative; 
    height: 500px; 
    z-index: 1; 
    position: relative; 
} 
.postcard-flip .card.flipped { 
    transform:rotatey(-180deg); 
    -ms-transform:rotatey(-180deg); /* IE 9 */ 
    -moz-transform:rotatey(-180deg); /* Firefox */ 
    -webkit-transform:rotatey(-180deg); /* Safari and Chrome */ 
    -o-transform:rotatey(-180deg); /* Opera */ 
} 
.postcard-flip .card { 
    -webkit-transform-style: preserve-3d; 
    -webkit-transition: 0.5s; 
    -moz-transform-style: preserve-3d; 
    -moz-transition: 0.5s; 
    -ms-transform-style: preserve-3d; 
    -ms-transition: 0.5s; 
    -o-transform-style: preserve-3d; 
    -o-transition: 0.5s; 
    transform-style: preserve-3d; 
    transition: 0.5s; 
} 
.postcard-flip .card .face { 
    position: absolute; 
    z-index: 2; 
    text-align: center; 
    backface-visibility: hidden; /* W3C */ 
    -webkit-backface-visibility: hidden; /* Safari & Chrome */ 
    -moz-backface-visibility: hidden; /* Firefox */ 
    -ms-backface-visibility: hidden; /* Internet Explorer */ 
    -o-backface-visibility: hidden; /* Opera */ 
} 
.postcard-flip .card .front { 
    position: absolute; 
    z-index: 1; 
    cursor: pointer; 
} 
.postcard-flip .card .back { 
    color: black; 
    cursor: pointer; 
    transform:rotatey(-180deg); 
    -ms-transform:rotatey(-180deg); /* IE 9 */ 
    -moz-transform:rotatey(-180deg); /* Firefox */ 
    -webkit-transform:rotatey(-180deg); /* Safari and Chrome */ 
    -o-transform:rotatey(-180deg); /* Opera */ 
} 

JS代碼:

$(document).ready(function() { 
    /* Card flip */ 
    $(".flip").hover(function(){ 
     $(this).find(".card").toggleClass("flipped"); 
     return false; 
    }); 
}); 
+0

你看到背面? (有關主題文本的更多信息的白色方塊) – dutchman711

+0

哈利 - 當然會的。謝謝你的幫助。 – dutchman711

+0

檢查[this](http://jsbin.com/gajofawega/2/edit)是否適合你。它在IE11中適用於我,但會帶來非常不好的效果。 [這](http://stackoverflow.com/questions/25104850/flipping-card-issue/25105063#25105063)是我前面寫的一個不同的答案,與這個問題鬆散地相關。你可能會覺得它很有用。 – Harry

回答

1

我結束了使用解決方案由jbutler483從David Walsh博客提出,因爲它具有平滑的翻轉效果,並可在所有瀏覽器中工作。在這裏我的代碼:

HTML:

<div class="flip-container y-flip-wrapper" ontouchstart="this.classList.toggle('hover');"> 
    <div class="flipper"> 
     <div class="front text-center"> 
      <!-- front content --> 
      <div class="y-theme-icon"> 
       <img src="image.png" height="90" alt=""> 
      </div> 
     </div> 
     <div class="back text-center"> 
      <!-- back content --> 
      <p>More information about this subject.</p>  
     </div> 
    </div> 
</div> 

CSS:

/* entire container, keeps perspective */ 
.flip-container { 
    perspective: 1000; 
    transform-style: preserve-3d; 
    display: inline-block; 
} 

/* UPDATED! flip the pane when hovered */ 
.flip-container:hover .back { 
    transform: rotateY(0deg); 
} 
.flip-container:hover .front { 
    transform: rotateY(180deg); 
} 

.flip-container, .front { 
    width: 140px; 
    height: 140px; 
} 

.flip-container, .back { 
    width: 140px; 
} 


/* flip speed goes here */ 
.flipper { 
    transition: 0.6s; 
    transform-style: preserve-3d; 

    position: relative; 
} 

/* hide back of pane during swap */ 
.front, .back { 
    backface-visibility: hidden; 
    transition: 0.6s; 
    transform-style: preserve-3d; 

    position: absolute; 
    top: 0; 
    left: 0; 
} 
.back{ 
    margin-top: 24px; 
} 

/* UPDATED! front pane, placed above back */ 
.front { 
    z-index: 2; 
    transform: rotateY(0deg); 
} 

/* back, initially hidden pane */ 
.back { 
    transform: rotateY(-180deg); 
} 
+2

在ie11窗口中不起作用10 –