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 8028957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:17:20+00:00 2026-06-05T00:17:20+00:00

I have a magic line in my site’s navigation (it’s slides under hovered menu

  • 0

I have a “magic line” in my site’s navigation (it’s slides under hovered menu element and stay there if I’m on that URL already).

$(function() {
    var $el, leftPos, newWidth, $mainNav = $("#menu");

    $mainNav.append("<li id='magic-line'></li>"); // line with position
                                                    // absolute
    var $magicLine = $("#magic-line");
    // initialization
    if ($('.selected')[0].id == 'logo') { // we're on the main page
        $magicLine.width(1) // just hide
        .css({
            "left" : 100
        }).data("origLeft", 100).data("origWidth", 1);
    } else { // we're on the not-main page
        off = parseInt($('#menu > .selected').css('padding-left').slice(0, -2));
        leftPos = $("#menu > .selected").position().left + off;
        $magicLine.width($(".selected").width()) // stay under the menu
                                                    // element
        .css("left", leftPos).data("origLeft", $magicLine.position().left)
                .data("origWidth", $magicLine.width())
    }

    $("#menu > .nav-item").hover(function() { // go under the menu element
        $el = $(this);
        newWidth = $el.width();
        off = parseInt($el.css('padding-left').slice(0, -2));
        leftPos = $el.position().left + off;
        $magicLine.stop().animate({
            left : leftPos,
            width : newWidth
        }, 200);
    }, function() {
        $magicLine.stop().animate({
            left : $magicLine.data("origLeft"),
            width : $magicLine.data("origWidth")
        }, 200);
    });
});

And I detected some weird behaviour. It’s slightly different in each browser, but trend is the same: when I click on menu element – it go to the proper position (let’s say left 260px), I can click again and again, but it’s still there. But when I press F5 (or just typing the url) it’s appear in slightly different position (left 256px). So, I click on the same element and it’s again on proper position. And if I won’t stop it can drastically change and after F5 appear on proper position.

So what is the reason this behavior? Is it saves state somehow? What is the difference between F5 and just clicking? Only cause that I see at this moment is my django development webserver which is fully synchronously, slow and non-caching, but I can’t check it on production server.

  • 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-06-05T00:17:21+00:00Added an answer on June 5, 2026 at 12:17 am

    So, the problem was in custom fonts used in menu (@font-face) and the related width.
    If font is changed to one from the safe list (Arial, Verdana) it’s rendered and behaves as I expect, but when custom typeface is used it’s collapses. By the way, the browser’s JS console gave me this warning: “Resource interpreted as Font but transferred with MIME type application/x-font-otf”, but I don’t sure whether it related to the problem somehow.

    And my solution is simply declare the width for each element, so browser can render it correctly from outset.

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

Sidebar

Related Questions

Suppose I have: struct Magic { Magic(Foo* foo); Magic(Bar* bar); }; Is there a
I have a computer that's configured for magic WOL packets, so the adapter will
I have a menu that links to content on the same page and through
OCR texts often have words that flow from one line to another with a
I have an application that reads lines from a file and runs its magic
I have been developing our php based site on a development box that was
I have a problem with JavaScript magic. When I execute this code: var page
I have the following array: a = magic(12); a = a(:,1); It's a list
I have an application written in a language called magic. This application uses MSSQL
Imagine you have a file a.h #include <iostream> template<typename T> struct A{ int magic;

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.