Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble with using jQuery remove() on elements that are inline-block
    primarykey
    data
    text
    <p>I have a horizontal line of div elements that are <code>display:inline-block</code> and top aligned.</p> <p>I can add elements, and the line expands. When I remove elements by animating the width to 0, the line doesn't retain it's single line appearance, but rather forces a second line to temporarily appear during the animation.</p> <p>The behavior is the same in IE, Webkit and Firefox.</p> <p>I could change the interface to avoid the problem, but I still would like to know what causes it, and how to fix it if possible. </p> <p>Here's a scaled-down example of the issue.</p> <pre><code>body { text-align: center; } #container { height: 20px; border: 1px dashed #AAA; background: #EEE; margin: 0 auto; display:table !important; display: -moz-inline-stack; /* Pre FF3 fix */ display: inline-block; zoom: 1; /* IE fix */ *display: inline; /* IE fix */ } .item { cursor: pointer; width: 50px; height: 18px; border: 1px solid purple; vertical-align: top; display: inline-block; color: white; vertical-align: top; display: -moz-inline-stack; /* Pre FF3 fix */ display: inline-block; zoom: 1; /* IE fix */ *display: inline; /* IE fix */ } .outer { background: orange; } $('#add').click(function() { $(this).before('&lt;div class="item"&gt;&lt;/div&gt;') }); $('#add').click().click().click() $('.item:not(.outer)').live('click', function() { $(this).animate({width: 1, paddingLeft: 0}, 1000, function() {$(this).remove()}); }); &lt;div id="container"&gt;&lt;div class='item outer'&gt;&lt;/div&gt;&lt;div id="add" class="item outer"&gt;Add&lt;/div&gt;&lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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