need to total width of rotating images

感情迁移 提交于 2019-12-13 18:19:16

问题


I have an effect that when you hover over this one particular area, it raises it from the bottom, rotates the images, and scrunches them together. It is supposed to emulate "fanning out" a hand of playing cards. It all works well and good except I need them to be centered. The only way I can think how to do that is to measure the farthest corner on each side, but I don't know how to do that. Anyone have any suggestions? I'm using jQuery 1.7.

Link to example: http://aws.redemptionconnect.com/redemption/play.html


回答1:


Instead of using javascript to calculate screen widths, it is much easier to become a little creative with margin: auto

First, give the cards a predefined left value depending on the cards position in the stack.

Then we calculate the width of #outer-hand wrapper. Once we have the proper width, the margin defined to auto will automatically center the cards to the desired position!

Take a look at this:

http://jsfiddle.net/JE7gf/



来源:https://stackoverflow.com/questions/11194631/need-to-total-width-of-rotating-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!