css3 3d变换卡翻转,padding/margin/border会导致旋转原点混乱,如何解决这个问题?
http://jsfiddle.net/nicktheandroid/yWKMD/
看一下示例,当您单击该元素时,它从前
旋转到后
,问题是它没有绕中心旋转,就像失去平衡一样,将鼠标放在左边框上在 front
侧,单击该元素,然后查看 back
侧的位置现在如何关闭。它们应该放置在完全相同的位置。
我注意到,当我删除填充/边距/边框时,它会旋转得很好,但我需要在那里添加填充和边框。有没有办法用填充和边框来做到这一点 - 以便它围绕中心旋转,而不是偏离侧面?
http://jsfiddle.net/nicktheandroid/yWKMD/
Look at the example, when you click the element, it rotates around from the front
to the back
, the problem is that it's not rotating around it's center, it's like it's off balance, hold your mouse at the left border of the front
side, click the element, and see how the back
side's position is now off. They should be positioned in exactly the same spot.
I noticed that when I removed the padding/margin/border, it would rotate fine, but I need to have the padding and border on there. Is there a way to do this with padding and a border - so that it will rotate around the center, not off to the side?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
内部 div (#card div) 太宽 (235 + 50 + 2) 和/或 #card 太窄 (245)。您必须将内边距和边框添加到总宽度,或者使用
box-调整大小:border-box
(带有供应商前缀)。The inner divs (#card div) are too wide (235 + 50 + 2) and/or #card too narrow (245). You must add padding and border to total width, or alternatively use
box-sizing: border-box
(with vendor prefixes).您可以通过在“翻转”div 上使用负边距来解决此问题。
http://jsfiddle.net/gmsitter/jm80wv7b/
You can get around this by using a negative margin on the "flipped" div.
http://jsfiddle.net/gmsitter/jm80wv7b/