Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery animation menu height
    primarykey
    data
    text
    <p>Hey all i have the following jsfiddle > <a href="http://jsfiddle.net/tQ2xT/" rel="nofollow">Fiddle</a> that i need some help on.</p> <p>When i have my mouse over it-it expands out to a static width but, depending on the text length, it grabs it by the inner's text <strong>$('.inner').height()</strong>.</p> <p>Problem being is that it goes a little too far beyond the last text list item and when i roll over any of the text in the menu box it slides back up a little. How can prevent it from (1) sliding back up and (2) have the exact height needed without even having the extra space at the bottom of the box for its height?</p> <p><strong>The JS:</strong></p> <pre><code>$(document).ready(function() { $('#menuSquare, .inner').mouseout(function() { theMenu('close'); }); $('#menuSquare, .inner').mouseover(function() { theMenu('open'); }); }); function theMenu(what2Do) { if (what2Do == 'open') { $('#menuSquare').stop().animate({ width: 190, //95 height: $('.inner').height(), duration:900, 'padding-top' : 10, 'padding-right' : 10, 'padding-bottom' : 10, 'padding-left' : 10, backgroundColor: '#fff', opacity: 0.8 }, 1000,'easeOutCubic') } else { $('#menuSquare').stop().animate({ width: "20", height: "20", padding: '0px', backgroundColor: '#e51937', opacity: 0.8 }, 500,'easeInCirc') } }​ </code></pre> <p><strong>The HTML:</strong></p> <pre><code>&lt;div id="menuSquare" class="TheMenuBox" style="overflow: hidden; width: 20px; height: 20px; background-color: rgb(229, 25, 55); opacity: 0.8; padding: 0px;"&gt; &lt;div class="inner"&gt; &lt;p style="text-decoration:none; color:#666; cursor: pointer; " onclick="changeImg('Custom Homes');"&gt;Custom Homes&lt;/p&gt; &lt;p style="text-decoration:none; color:#666; cursor: pointer; " onclick="changeImg('Full Service Hotels');"&gt;Full Service Hotels&lt;/p&gt; &lt;p style="text-decoration:none; color:#666; cursor: pointer; " onclick="changeImg('Mixed Use');"&gt;Mixed Use&lt;/p&gt; &lt;p style="text-decoration:none; color:#666; cursor: pointer; " onclick="changeImg('Office');"&gt;Office&lt;/p&gt; &lt;p style="text-decoration:none; color:#666; cursor: pointer; " onclick="changeImg('Retail');"&gt;Retail&lt;/p&gt; &lt;p style="text-decoration:none; color:#666; cursor: pointer; " onclick="changeImg('Select Service Hotels');"&gt;Select Service Hotels&lt;/p&gt; &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.
    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