• Resolved charchub

    (@charchub)


    Hi all,

    I am working on a WordPress instalation which uses a navbar menu based on bootstrap. When the screen is smaller than a certain size, the menu changes into a three line drop-down.

    Previously, the menu 0px border to top but I changed it to 32px because I wanted to use the multix bar plugin to add a an extra menu on top of it (see the demo here: https://www.charchub.com/en).

    Everything works fine but when I resize the screen, a space appears between two menus: It seems that somehow in smaller screen, the bootstrap nav bar is shifted few pixels down which creates this space. How can I solve this? I really appreciate all your support.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Use media queries in CSS, e.g;

    @media all and (max-width: 38em) {
    
     nav {
      position: fixed;
      top: 0;
     }
    
    }

    Thread Starter charchub

    (@charchub)

    Thanks Andrew,

    This was an interesting post and very insightful: I tried to do something like this without luck:(

    @media all and (max-width: 4500px) and (min-width: 1200px) {

    #topmenu .navbar-inner {
    position: fixed;
    border-top: 32px;
    }
    }

    I noticed that, when the drop-down (three line menu) becomes activated, it recognizes the top menu and therefore border-top: 0px; puts two menus under each other in a neat way.

    However, on the standard size, this does not happen. So as you can see in the link in my previous post, one menu covers the other one.

    If I use something like this:

    #topmenu {border-top:32px;}

    Then the standard screen gets fixed but on the smaller screens, there is a 32px space between two menus.

    What did I do wrong? Any thoughts?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    There’s nothing apparently wrong from the CSS you wrote (above), can you link the webpage with the issue?

    Thread Starter charchub

    (@charchub)

    Aboslutely:

    This is the link: https://www.charchub.com/en

    If you go to this page, you see two menus are overlapping, because in the #topmenu the border-top is set as 0px.

    If you resize and make the screen smaller, though, you sill see both menus. Now, if I set the border-top as 32px (which is the height of the black menu on top), the full screen will look perfect, but on a smaller screen, there will be a 32px space between the top and three line menu.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    How about using the ‘top‘ position to move ‘#topmenu‘ down?

    .navbar-fixed-top {
     top: 34px;
    }

    Thread Starter charchub

    (@charchub)

    I can send you my admin if you want to take a look at the css stylesheet: May I have your email?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Sorry we encourage support to be kept on these forums so that anyone else who is experiencing the same issue is not left out when they visit forum threads.

    Thread Starter charchub

    (@charchub)

    Sure; I understand and I appreciate your great help. Actually I was impressed and surprised by all this great support.

    I used this and it didn’t fix it:(

    #topmenu .navbar-fixed-top {
    top: 34px;
    }

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Hi again Charchub, you’ve accidentally used a hash character instead of a full stop character.

    Try this:

    .navbar-fixed-top {
     top: 34px;
    }

    Thread Starter charchub

    (@charchub)

    Andrew, Thank you so much! It fixed it: I didn’t add the code at the right place, but then I added under the right part of the code and it did the trick.

    You are awesome!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Question: How to fix the navbar position to the top once the screen is resized?’ is closed to new replies.