Sticky menu causing trouble

My Wordpress site has a sticky menu implemented using CSS position: fixed in the header section. However, this sticky menu is overlaying over each of my website sections. To see what I mean, visit the test site here.

If you click on the menu icon and navigate to a specific section, you'll notice that the sticky menu remains at the top, overlapping the content. What I actually need is for the sticky menu to stay above each section instead of covering them.

In my header.php file, the code looks like this:

<div id="header-wrap">
    <div class="poweredby">POWERED BY bluesource<p class="mobile-phone"><a href="tel: +44 0845 319 2100">0845 319 2100</a></p></div>
    <div class="headerphone">0845 319 2100</div>
    <button class="toggle-menu menu-right push-body"><i class="fa fa-bars"></i></button>
        <!-- Right menu element-->
        <?php if ( has_nav_menu( 'primary' ) || has_nav_menu( 'social' ) ) : ?>
            <?php if ( has_nav_menu( 'primary' ) ) : ?>
                <nav id="site-navigation" class="cbp-spmenu cbp-spmenu-vertical cbp-spmenu-right" role="navigation" aria-label="<?php esc_attr_e( 'Primary Menu', 'twentysixteen' ); ?>">
                    <?php
                        wp_nav_menu( array(
                        'theme_location' => 'primary',
                        'menu_class'     => 'primary-menu',
                        ) );
                    ?>
                </nav> 
            <?php endif; ?>
        <?php endif; ?>
</div><!-- end header wrap -->

In my stylesheet, the relevant CSS code can be found below:

.site-header {
    background: #333 none repeat scroll 0 0;
    height: 98px;
    padding: 27px 0;
    text-align: right;
}

.site-header-main {
    text-align: right;
    right: 0;
    display: block;
    padding-right: 27px;
}

#header-wrap {
    background: #333;
    position: fixed;
    top: 0;
    z-index: 100;
    height: 98px;
    padding-top: 27px;
    padding-right: 27px;
    opacity: 0.9;
}

Answer №1

This is the solution you need

$('#header-wrap ul li a').click(function(){
    href=$(this).attr('href');
    $('html, body').animate({
      scrollTop: $(href).offset().top-98  // adjusting for nav height of 98px
    }, 500);
});

When dealing with external links

$(document).ready(function(){
   var urlHash = window.location.href.split("#")[1];
    $('html,body').animate({
        scrollTop: $('#' + urlHash).offset().top-98 
    }, 500);
});

Answer №2

Here's a solution that should work for you. Adjusted the positioning to display the white bar on the side, and added an important tag to prevent it from being overridden.

nav#site-navigation {
    top: 98px;
}
.cbp-spmenu-right.menu-open {
    right: 23px !important;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unlocking the res property in index.js from an HTML script tag: A step-by-step guide

Can anyone help me with the access variable issue I am facing? I have two files, index.js and page.ejs. These files require me to create a timer linked with datetimes stored on my local server. //index.js.. router.get('/mieiNoleggi', functio ...

how can the class hide be removed when hovering over each link

How can I remove the class hide from a div with the class popover when hovering over each link? I have tried implementing the code below, but it doesn't seem to be working as expected. $(document).ready(function() { $(".myPopover").each(function( ...

The .keypress() function isn't behaving as expected

I've encountered a coding dilemma. Below is the code in question: $(document).ready(function () { var selectedDay = '#selected_day'; $(function () { $("#date").datepicker({ dateFormat: "DD, d M yy", a ...

When extracting information from a table within a Vue.js and Vuetify.js function

When trying to display a table, only one row is being printed. How can I resolve this issue? I have attempted various solutions (Vanilla JS worked). This project is for educational purposes and I am relatively new to JS and Vue.js. <template> < ...

The browser encountered an issue trying to load a resource from a directory with multiple nested levels

I've stumbled upon an unusual issue. Here is a snapshot from the inspector tools. The browser is unable to load certain resources even though they do exist. When I try to access the URL in another tab, the resource loads successfully. URLs in the i ...

The background colors are not extending to the full width of the screen

I am facing an issue in my CSS code while trying to create a footer. The background color is not filling the width of the screen, and I had encountered the same problem earlier. Here is how it looks: (https://i.sstatic.net/5VxYU.png) HTML Code: *{ ma ...

JavaScript image search function within the existing page

Building a HTML website is new to me and I lack basic programming skills. I've uploaded 100 animated images to another server and linked them to my HTML website using code like this: <p> <img src="http://.../abc/23118465.gif" alt="teddy be ...

Is it possible to connect a JavaScript file to an HTML document within a React application?

I have been developing a React website with the following file structure: public: index.html second.html src: index.js second.js table.js forms.js The main page (index.js) contains both a form and a table. One of the columns in the table has a link t ...

Creating a dynamic and engaging website using a combination of Flash elements, Div or HTML overlays, and M

In my efforts to overlay HTML over SWF objects, I've experimented with various CSS styles but encountered a few obstacles. Issue on Safari 4.0.3 PC: The SWF object consistently appears above the HTML content. Problem in Firefox 3.5.6 PC: While the ...

Intersection of content in panel-body using bootstrap tab pills

Can someone help me solve a major issue? I need the content of each tab to overlap as if they are unaware of each other. Currently, my code is saved in this fiddle: https://jsfiddle.net/axq882de/1/. When I click on different tabs, the contents should remai ...

Changing the entire content of a webpage from the server using AJAX

I am looking to update the entire page content with the click of a button, transitioning from Words.html to SelectNumber.html This snippet is from Words.html <html> <head> <meta charset="UTF-8"> <title>Number Game< ...

The Div element containing the rollover button/picture is failing to resize properly as the window is decreased in size

Whenever I try to resize my browser window in Firefox or Chrome, the div ends up moving instead of resizing. I've searched on stackoverflow for answers but haven't found any solutions yet. Can someone please help me with this issue? Here is what ...

"Enhancing Website Styling with Twitter Bootstrap's Border

Recently delving into the realm of Twitter Bootstrap, I find myself pondering on the best approach to incorporate a border around a parent element. Consider this scenario: <div class="main-area span12"> <div class="row"> <div cl ...

Tips for eliminating the gap between Bootstrap 4 columns

Is there a way to eliminate the spacing between Bootstrap columns? I have three columns set up using Bootstrap but no matter what I do, I can't seem to get rid of the space between them. <!doctype html> <html lang="en> <head> ...

The function of the Django 2 model is not being identified within the index.html file

Hello everyone, I'm a newcomer to the world of Django so please go easy on me! I am currently working on creating a blog in Django and I've encountered an issue. I need to map the posts from the home page to the post page. To achieve this, I have ...

How can I position 7 images absolutely within a specific div?

I've been working on a website where users can have their avatars displayed using a JS function that loads 7 different images onto the page. These images correspond to different elements such as skin base, hair, eyes, mouth, shirt, shoes, and pants, a ...

Execute the JavaScript [ window:print() ] function once the webpage has finished loading along with any

I am facing an issue with my web page that has around 10 Google Analytics charts. I want to trigger a print dialog box once the page is fully loaded, including all the charts and JavaScript. Currently, the problem is that the print dialog box opens after t ...

How can we apply position: fixed in print media queries using CSS?

In order to display a footer on every printed page, we have implemented the use of position: fixed. However, one issue that has arisen is that content ends up flowing underneath the footer. Is there a solution to prevent this from happening while still k ...

Display an Image using the <img> tag with the help of PHP

I have a simple question that I can't seem to figure out. I want to display an image in an src tag loaded from a PHP MySQL database. Here's what I've tried: <ul> <?php $sql = "SELECT * FROM advertisement_ ...

Having trouble retrieving HTML content from WKWebView in Swift

Unfortunately, I'm facing an issue where I am unable to retrieve the HTML content of a web page using the following code: webView.evaluateJavaScript("document.getElementsByTagName('html')[0].innerHTML") The web page contains two sets of HTM ...