Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I ensure that my jquery horizontal accordion always takes up 100% width?
    primarykey
    data
    text
    <p>I'm trying to develop my own horizontal accordion without having to use a plugin. It should take up the full browser-window width. The accordion sections open on mouseenter.</p> <p>It's more-or-less working (providing the section is allowed to expand fully before hovering over another one), however, if the sections are hovered over quickly the entire width of the accordion shrinks as the 'selected' section takes longer to grow than the smaller section.</p> <p>I need to make the accordion maintain the 100% browser-width, but I'm not sure what I need to be doing to achieve this.</p> <p>I have created a jsFiddle to illustrate (<a href="http://jsfiddle.net/AUu9E/" rel="nofollow">http://jsfiddle.net/AUu9E/</a>), run the mouse across them quickly to see the problem I'm trying to solve.</p> <p>Many thanks in advance.</p> <pre><code>var qtySect = 6; var windowWidth = $(window).width(); var selectedWidth = windowWidth * 0.7; var unselectedWidth = windowWidth * 0.3 / (qtySect - 1); $("nav ul li").fadeTo(0,0.6); //set initial widths $(".unselected").css("width", unselectedWidth); $(".liHome").css("width",selectedWidth).addClass("selected"); //mouseover animate $("nav ul li").mouseenter(function() { if ($(this).hasClass("unselected")){ $(this).animate( { width: selectedWidth }, { queue: false, duration: 1000, easing: "linear" } ) $(".selected").animate( { width: unselectedWidth }, { queue: false, duration: 1000, easing: "linear" } ); $(".selected").addClass("unselected").removeClass("selected"); $(this).addClass("selected").removeClass("unselected"); } }); </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