我遇到了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