I am working on a memory matching game. Right now, when the user clicks on two identical images, they are removed. This part of the game works fine. When the images are removed, I want the other images to stay in place. However, they are shifting towards each other and not leaving space.
Demo: http://jsfiddle.net/kevinferri/bCP4G/
For example, click on the two flowers in the middle column. You will see that the the two outer columns will shift towards each other and fill that empty space. How can I change it so the images will stay in place after others are removed?
You probably don’t want to be
.remove()-ing elements if you want to the DOM to remember their original layout spacing and sizes. You want to just chuck those elements into hidden visibility so that they’re hidden, but they maintain their size and position.That’s
visibility:hiddenin CSS. Do take note of the difference between that and.show()/.hide()or even CSSdisplay:none.