Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1111193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:30:35+00:00 2026-05-17T02:30:35+00:00

This is my first time using JQuery in any of my projects. I have

  • 0

This is my first time using JQuery in any of my projects.

I have implemented the superfish menu.

On some of my pages I have a horizontal scroll. I would like to make the menu float on the center of the page as the page is scrolled.

Also I need to make sure that the submenu on the far right hand side of the menu does not open up off the page. When I hover on the right most element it opens up half off the page.

Any ideas on how to fix these two things?

I’m perfectly willing to use a different Jquery menu if there is a better one that has these features built in…

Thanks!

javascrupt call in my page:

$(document).ready(function () {
        $("ul.sf-menu").supersubs({
            minWidth: 12,   // minimum width of sub-menus in em units 
            maxWidth: 27,   // maximum width of sub-menus in em units 
            extraWidth: 1     // extra width can ensure lines don't sometimes turn over 
            // due to slight rounding differences and font-family 
        }).superfish({ animation: { opacity: 'show', height: 'show' }, autoArrows: false });  // call supersubs first, then superfish, so that subs are 
        // not display:none when measuring. Call before initialising 
        // containing tabs for same reason. 

I can post any more code that is needed, but there is quite a lot of code in the superfish files so i’m not sure what I should post.

I found this script and it works well, however when I scroll right the horizonal menu starts to stack so the menu items are side by side rather then vertical. I want to modify this to keep the menu horizonal…

<script type="text/javascript"><!--
            var floatingMenuId = 'floatdiv';
            var floatingMenu =

{
targetX: -1000,
targetY: 10,

hasInner: typeof (window.innerWidth) == 'number',
hasElement: document.documentElement
    && document.documentElement.clientWidth,

menu:
    document.getElementById
    ? document.getElementById(floatingMenuId)
    : document.all
      ? document.all[floatingMenuId]
      : document.layers[floatingMenuId]

};

            floatingMenu.move = function () {
                if (document.layers) {
                    floatingMenu.menu.left = floatingMenu.nextX;
                    floatingMenu.menu.top = floatingMenu.nextY;
                }
                else {
                    floatingMenu.menu.style.left = floatingMenu.nextX + 'px';
                    floatingMenu.menu.style.top = floatingMenu.nextY + 'px';
                }
            }

            floatingMenu.computeShifts = function () {
                var de = document.documentElement;

                floatingMenu.shiftX =
    floatingMenu.hasInner
    ? pageXOffset
    : floatingMenu.hasElement
      ? de.scrollLeft
      : document.body.scrollLeft;
                if (floatingMenu.targetX < 0) {
                    if (floatingMenu.hasElement && floatingMenu.hasInner) {
                        // Handle Opera 8 problems    
                        floatingMenu.shiftX +=
            de.clientWidth > window.innerWidth
            ? window.innerWidth
            : de.clientWidth
                    }
                    else {
                        floatingMenu.shiftX +=
            floatingMenu.hasElement
            ? de.clientWidth
            : floatingMenu.hasInner
              ? window.innerWidth
              : document.body.clientWidth;
                    }
                }

                floatingMenu.shiftY =
    floatingMenu.hasInner
    ? pageYOffset
    : floatingMenu.hasElement
      ? de.scrollTop
      : document.body.scrollTop;
                if (floatingMenu.targetY < 0) {
                    if (floatingMenu.hasElement && floatingMenu.hasInner) {
                        // Handle Opera 8 problems    
                        floatingMenu.shiftY +=
            de.clientHeight > window.innerHeight
            ? window.innerHeight
            : de.clientHeight
                    }
                    else {
                        floatingMenu.shiftY +=
            floatingMenu.hasElement
            ? document.documentElement.clientHeight
            : floatingMenu.hasInner
              ? window.innerHeight
              : document.body.clientHeight;
                    }
                }
            }

            floatingMenu.doFloat = function () {
                var stepX, stepY;

                floatingMenu.computeShifts();

                stepX = (floatingMenu.shiftX +
    floatingMenu.targetX - floatingMenu.nextX) * .07;
                if (Math.abs(stepX) < .5) {
                    stepX = floatingMenu.shiftX +
        floatingMenu.targetX - floatingMenu.nextX;
                }

                stepY = (floatingMenu.shiftY +
    floatingMenu.targetY - floatingMenu.nextY) * .07;
                if (Math.abs(stepY) < .5) {
                    stepY = floatingMenu.shiftY +
        floatingMenu.targetY - floatingMenu.nextY;
                }

                if (Math.abs(stepX) > 0 ||
    Math.abs(stepY) > 0) {
                    floatingMenu.nextX += stepX;
                    floatingMenu.nextY += stepY;
                    floatingMenu.move();
                }

                setTimeout('floatingMenu.doFloat()', 20);
            };

            // addEvent designed by Aaron Moore    
            floatingMenu.addEvent = function (element, listener, handler) {
                if (typeof element[listener] != 'function' ||
   typeof element[listener + '_num'] == 'undefined') {
                    element[listener + '_num'] = 0;
                    if (typeof element[listener] == 'function') {
                        element[listener + 0] = element[listener];
                        element[listener + '_num']++;
                    }
                    element[listener] = function (e) {
                        var r = true;
                        e = (e) ? e : window.event;
                        for (var i = element[listener + '_num'] - 1; i >= 0; i--) {
                            if (element[listener + i](e) == false)
                                r = false;
                        }
                        return r;
                    }
                }

                //if handler is not already stored, assign it    
                for (var i = 0; i < element[listener + '_num']; i++)
                    if (element[listener + i] == handler)
                        return;
                element[listener + element[listener + '_num']] = handler;
                element[listener + '_num']++;
            };

            floatingMenu.init = function () {
                floatingMenu.initSecondary();
                floatingMenu.doFloat();
            };

            // Some browsers init scrollbars only after    
            // full document load.    
            floatingMenu.initSecondary = function () {
                floatingMenu.computeShifts();
                floatingMenu.nextX = floatingMenu.shiftX +
    floatingMenu.targetX;
                floatingMenu.nextY = floatingMenu.shiftY +
    floatingMenu.targetY;
                floatingMenu.move();
            }

            if (document.layers)
                floatingMenu.addEvent(window, 'onload', floatingMenu.init);
            else {
                floatingMenu.init();
                floatingMenu.addEvent(window, 'onload',
    floatingMenu.initSecondary);
            }    

    </script> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:30:36+00:00Added an answer on May 17, 2026 at 2:30 am

    I’m not sure on how you mean centering, but if you mean horizontally centered:

    Could you separate the main page (that horizontally overflows) and the menu into separate div’s? e.g.

    <div id="menu"><center><ul class="sf-menu">...</ul></center></div>
    <div id="mainpage" style="overflow:auto;">Contents goes here</div>
    

    (the <center> tag might have to be <div style="width:X;margin:0 auto;"> depending on how superfish works)

    On the menu going over the page, sorry I’ll have to defer to someone more knowable to answer that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first time using jQuery and I am pleased to get my
This is my first time using lightbox which uses jquery framework. But when I
So this is my first time using cookies and i'm having some trouble setting
this is my first time using jquery, and i dont think it seems to
This is the first time I am using jQuery. I am loading a large
This is my first time using jQuery (I'm familiar with Java) and I've followed
I'm using Ajax via jQuery for the first time ever. I have an html
This is my first time with jQuery Mobile and I'm actually using it from
This is my first time using XML documents. What I'm trying to do is
This is my first time using this site and I am quite new to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.