Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to dynamically move list items inside a DIV to get proper arrangement?
    primarykey
    data
    text
    <p>I have a some images displayed using list items inside a div. With simple CSS float:left tricks, I am able to get the following layout: <img src="https://i.stack.imgur.com/QNQ4F.jpg" alt="current"></p> <p>But I was them to dynamically arrange based on div width and height and want something like this: <img src="https://i.stack.imgur.com/mV7Tq.jpg" alt="wished"></p> <p>Let me know if there is any way to achieve the same using CSS, JavaScript or jQuery.</p> <p>Also, let me know if these sample screenshots does not help and HTML code is needed.</p> <p>Thanks</p> <p>EDIT: Adding image after applying masonry plugin (see image 3 below). Now I have equal number of images and they are equally spaced and with proper gutter. But it is always aligned to left. How can this always be centered aligned?</p> <p>I have the following code:</p> <pre><code>&lt;div id="container"&gt; &lt;img src="" class="myimage"&gt; &lt;img src="" class="myimage"&gt; &lt;img src="" class="myimage"&gt; &lt;img src="" class="myimage"&gt; &lt;/div&gt; </code></pre> <p>And jQuery for masonry part:</p> <p>$('#container').masonry({ "gutter": 10, itemSelector: '.myimage' }); </p> <p><img src="https://i.stack.imgur.com/PB2vT.jpg" alt="enter image description here"></p> <p>EDIT 2: Also made a jsfiddle to show the problem with right margin after applying masonry plugin. Please resize browser also to see right gap in each case: <a href="http://jsfiddle.net/5KyRd/7/" rel="nofollow noreferrer">http://jsfiddle.net/5KyRd/7/</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload