jquery - Prevent CSS drop-down menu from extending beyond screen to the right -


i have horizontal css drop-down menu in header of site. menu floated right in header also. having problem when mouseover menu , drop downs, if dropdowns have sub menus have sub menus, menus begin fly off screen right can't see them , horizontal scroll bar. menu created using list items (i have removed ton of items brevity):

<nav id="main-menu"  role="navigation">       <div class="menu-navigation-container">       <ul class="menu">                   <li class="last expanded">             <a href="/content/clients" title="clients">clients</a>             <ul class="menu">                <li class="first expanded">                   <a href="/content/information-technology-client" title="it client services">information technology</a>                   <ul class="menu">                      <li class="first expanded">                         <a href="/content/enterprise-applications-client" title="client enterprise applications">enterprise applications</a>                         <ul class="menu">                            <li class="first leaf"><a href="/content/oracle-client" title="oracle client services">oracle</a></li>                            <li class="leaf"><a href="/content/peoplesoft-client" title="peoplesoft client services">peoplesoft</a></li>                            <li class="leaf"><a href="/content/sap-client" title="sap client services">sap</a></li>                            <li class="leaf"><a href="/content/lawson-client" title="lawson cilent services">lawson</a></li>                            <li class="leaf"><a href="/content/hyperion-client" title="customer relationship management client services">hyperion</a></li>                            <li class="leaf"><a href="/content/jd-edwards-client" title="jd edwards client services">jd edwards</a></li>                                                        </ul>                      </li>                                        </ul>                </li>                            </ul>          </li>       </ul>    </div>    <div class="clear"></div> </nav> <!-- end main-menu --> 

so when "enterprise applications" menu flying off screen can't see it. have limited control on html of menu, generated system. cannot create additional id's or classes. can work have shown here. can add jquery custom file address this. can think of jquery (or plain vanilla javascript matter) might able prevent list items flying off screen? also, intranet app, unfortunately can't send demo. oh , have access external css file can add additional css, can't add/edit id's , classes of menu itself.

thanks

i ended doing , seems work.

$('#main-menu li').mouseenter(function() {   //make sure menu not fly off right of screen   if ($(this).children('ul').offset().left + 200 > $(window).width()) {            $(this).children('ul').css('right', 180);             }  }); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -