jquery Masonry, add a new div in the center of the div#container

本小妞迷上赌 提交于 2020-01-24 21:08:21

问题


I have some DIV's in my HTML and I want click some div's then add a new div in the center of the div#container. and the page could reload, put the first pieces div's around this new div.

however, this is what i need

Here is my code, http://jsfiddle.net/PQGGT/
there is still have a window resize function.


回答1:


My course of action in the solution was to center the new element by appending it to the right position in the container by calculating where it should be located, iterate through the box elements while totaling their widths and prepending the centered element in the right position with the appropriate margins to have it perfectly centered.

You can see my solution here: http://jsfiddle.net/PQGGT/4/

I had to fix a few small things in your code to make it run in the first place.



来源:https://stackoverflow.com/questions/6661882/jquery-masonry-add-a-new-div-in-the-center-of-the-divcontainer

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