要产生非常基本的视差滚动效果,下面的示例就足够了。 请注意,浏览器前缀,后备等未得到解决。标
有的CSS值可以由设计人员决定是否更改。在这里看到我的[叉子]
<html><head><style> html, body { width: 100%; height: 100%; overflow: auto; } body { perspective: 1px; } .background { transform: translateZ(-.4px) scale(.6) translateX(-104%) translateY(-40%) rotate(-5deg); } .foreground { transform: translateZ(.25px) translateX(50%) scale(.75) rotate(2deg); }</style></head><body> <img /> <img /></body></html>对KitKat的回答进行了较小的修正:似乎不需要
transform-style:preserve-3d(至少在Chrome中是这样),并且效果
取决于身体的
overflow:auto。删除它,视差就会失败。



