问题
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