我遇到了CSS 3D透視屬性的問題。3D中的3D透視
<figure>
<img src="http://www.saintbioz.fr/wp-content/uploads/2010/02/paysage-montagneux.jpg" width="512" height="384" alt="Landscape" />
<figcaption>Summer in the mountains</figcaption>
</figure>
只想動畫在figcaption:懸停從-90deg到0deg執行向下摺疊效果(像http://davidwalsh.name/demo/folding-animation.php),考慮到-90deg表示塊壓平(因此不可見)
/** vendor prefixes have been removed for better readability **/
figure {
display: inline-block;
position: relative;
line-height: 0;
perspective: 300px;
}
figcaption {
background-color: rgba(0,0,0,0.2);
padding: 20px 10px;
position: absolute;
top: 0;
right: 0;
left: 0;
transition-property: all;
transition-duration: 500ms;
transform: rotateX(-123deg);
transform-origin: top;
}
figure img:hover + figcaption {
transform: rotateX(0deg);
}
問題是,透視圖沒有給Chrome和Firefox提供相同的渲染。 我必須手動將figcaption默認轉換設置爲rotateX(-123deg);
,具體取決於500px的透視值,它在Chrome上運行良好,但在Firefox上無效。
理論上,當不是時:-hdeg應該是-90deg:hover和0deg在:hover時,但似乎perspective
屬性改變了深度字段的長度,所以-90deg不再有效。
我想知道爲什麼在使用perspective
和rotate
時最佳做法是什麼,以使其在所有最新的瀏覽器上都能正常工作?
此致敬禮。
PS:只要複製/粘貼HTML & CSS和嘗試在Chrome和FF,你應該立即看到什麼是錯;)
您好,感謝回答。 我的目標是在瀏覽器上按預期工作,而不管其他瀏覽器如何處理。 – jmpp 2012-07-31 09:54:49
提醒:現在是2016年.... – 2016-07-20 17:32:34