使用纯 CSS 进行 3D 变换
我正在尝试用纯CSS重建 this 。我已经这了。但正如您从 Flash 版本中看到的那样,当封面出现时,其他 div 会为悬停的 div 腾出空间。
我尝试将宽度设置为自动,并在该特定 div 上设置了过渡属性,但没有成功。我还尝试在悬停之前将 div 的宽度设置为 0,并在悬停时将其设置为 300px,这确实达到了目的,但它并没有真正实现动画。
它可能很简单,也可能不是,但无论哪种方式都很好朝着正确的方向推动!
谢谢。
I am trying to rebuild this with pure css. And I've got this far. But the idea as you can see from the flash version, is that as the cover appears the other divs make space for the one that is on hover.
I have tried to set the width on auto and have set the transitioning property on that particular div, but with no luck. I also tried to set the div's width to 0 before hover, and set it to 300px on hover, this did the trick but it did not really animate..
It could be something simple, or maybe not, but either way would be great to get a push in the right direction!
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您不需要 WebGL 浏览器,您可以通过简单的 3D 转换来完成此操作。
当您悬停时,您必须显式更改 div 的宽度,因为显式转换不会触发重新布局。您需要对本书的内容进行绝对定位。
您应该使用包装 div 来更改悬停宽度,并使用子 div 来进行转换。
嵌套是转变理智的关键。
这是显示其实际效果的 jsfiddle: http://jsfiddle.net/ZMqze/4/
需要多一点润色才能实现悬停。
You don't need a WebGL browser you can do this with plain 3D transforms.
You have to explicitly change the width of the divs when you hover because transforms explicitly don't trigger relayout. You'll need to position the contents of the book absolutely.
You should use a wrapper div for the hover width change and a child div for the transform.
Nesting is key to transform sanity.
Here is the jsfiddle that shows it in action: http://jsfiddle.net/ZMqze/4/
needs a little more polish for unhover.
您可以使用 CSS3 中的 3D 变换功能。它将使您获得您想要的效果。您可以创建两个
。一个用于正面,另一个用于背面。使用
z-index
使正面与背面重叠,并使用position:absolute
将它们放在同一位置。还可以通过设置 backface-visibilty: none 来使其背面不可见。然后将它们包裹在中,并为其添加翻转动画。
将脚蹼包裹在
透视中将允许动画为 3D(确保使用供应商前缀)。
翻转器必须具有相对位置,因为内部的两个元素将相互重叠并且将处于绝对位置(确保将供应商前缀添加到过渡和过渡样式)。
然后,您只需添加这段代码即可使翻转器在将鼠标悬停在其包装上时翻转。
此视频教程将有所帮助:http://www.youtube.com/watch?v=6ObIO -SjMZc
You can use 3D transformation features in CSS3. It will allow you to get your desired effect. You can create two
<div>
s. One for the front face and another for the back face. Make front face overlap the back face by usingz-index
and put them in the same position by usingposition: absolute
. Also make their backface invisible by settingbackface-visibilty: none
. Then wrap them up in<div class="flipper">
and add the flip animations to this.Wrap the flipper inside
<div class="container">
Perspective will allow the animation to be 3D(make sure to use vendor prefixes).
The flipper must have position relative because the two elements inside will be overlapping each other and will have been position absolute(make sure to add vendor prefixes to transition and transition-style).
Then you can just add this piece of code to make the flipper flip upon hover over its wrapper.
This video tutorial will help: http://www.youtube.com/watch?v=6ObIO-SjMZc
首先,您需要一个支持硬件加速的 webgl 浏览器(仅支持 windowsxp 下的 safari5,顺便说一句。以及适用于 linux 或 win7 的 webkitnightly custombuild)
,如果我稍后有更多时间,我会尝试为您提供准确的 css,但这些说明应该会引导您获得所需的结果。
first off, you need a webgl browser that supports hardware acceleration (thats only safari5 under windowsxp, btw. and webkitnightly custombuild for linux - or win7)
if I have some more time later on, I'll try to give you the exact css, but these instructions should lead you to your desired result.