Note that there are some explanatory texts on larger screens.

plurals
  1. POdynamic dropdown menu switching direction
    primarykey
    data
    text
    <p>I have a dynamic dropdown menu using jQuery where the number of main navigation links are dependent on a CMS. Is there way to make it so if the dropdown container touches the wrapper of the website then it flips sides and is right aligned so there is no overflow outside of the main webpage container? See <a href="http://online.wsj.com/home-page" rel="nofollow">http://online.wsj.com/home-page</a> as an example.</p> <p><strong>EDIT</strong></p> <p>Here is th code.</p> <pre><code>&lt;script&gt; $("ul#navBar li span").click(function() { //When trigger is clicked... //caching selectors var $this = $(this), $parent = $this.parent(), $siblings = $parent.siblings(), $dropdowns_siblings = $siblings.find('.dropdown'); $this.next().toggle(); //toggles the dropdown on click //hide other menus if visible $dropdowns_siblings.hide(); function rowWidth(){ //Calculate width of ul var rowWidth = 0; $parent.find("ul").each(function() {rowWidth += $(this).width(); }); //Set width of .dropdown $parent.find(".dropdown").css({'width' : rowWidth}); }; return rowWidth(); &lt;/script&gt; &lt;div id="container"&gt; &lt;ul id="navBar"&gt; &lt;li&gt;&lt;a href="/"&gt;Link 1&lt;/a&gt; &lt;span&gt;&lt;/span&gt; &lt;div class="dropdown"&gt; dynamic # of cols &lt;/div&gt; &lt;/li&gt; &lt;li&gt;&lt;a href="/"&gt;Link 1&lt;/a&gt; &lt;span&gt;&lt;/span&gt; &lt;div class="dropdown"&gt; dynamic # of cols &lt;/div&gt; &lt;/li&gt; &lt;li&gt;&lt;a href="/"&gt;Link 1&lt;/a&gt; &lt;span&gt;&lt;/span&gt; &lt;div class="dropdown"&gt; dynamic # of cols &lt;/div&gt; &lt;/li&gt; &lt;li&gt;&lt;a href="/"&gt;Link 1&lt;/a&gt; &lt;span&gt;&lt;/span&gt; &lt;div class="dropdown"&gt; dynamic # of cols &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre>
    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