Incorporating a stationary navigation bar alongside a parallax scrolling layout

After spending the entire night trying to figure this out, I have had zero success so far. I decided to tackle this issue with javascript since my attempts with CSS have been completely fruitless.

This is a demonstration of the parallax scrolling webpage.

This is the CSS code I used for the navigation bar:


#nav-wrap {
    #nav-wrap .container {
        clear: both;
        overflow: hidden;
        position: relative; 
    }
    
    #nav-wrap .container {
        position: fixed;
        top: 0;
        left: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 999;
        height: 48px;
        width: 100%;
        padding-top:1px;
        padding-right: 18px;
        margin: 0 auto;
        border-radius: 0px;

        -webkit-box-shadow: -1px 16px 25px -18px rgba(0,0,0,0.1);
        -moz-box-shadow: -1px 16px 25px -18px rgba(0,0,0,0.1);
        box-shadow: -1px 16px 25px -18px rgba(0,0,0,0.1);
    }
    
    #nav-wrap .container ul {
        position: relative;
        list-style: none;
        margin: 0 auto;
        float: right;
    }

    #nav-wrap .container ul li {
        width: 1; 
        height: 22;
        list-style: none;
        float: left;
        background:url(searchnavsep.pn) no-repeat right;
        padding-right:1px;
    }

    #nav-wrap .container ul > li:first-child a,
    #nav-wrap .container ul > li:first-child a:hover,
    #nav-wrap .container ul span:first-child li a,
    #nav-wrap .container ul span:first-child li a:hover{
        border-radius:0px 0px 0px 0px;
    }

    #nav-wrap .container ul li a {
        float: right;
        display: block;
        margin-top: 3%;
        margin-right: 30%;
        font-family: 'Clear Sans', sans-serif;
        font-weight: normal;
        color: rgba(255, 255, 255, 0.78);
        padding: 0px 24px;
        bottom: 1px;
        border: 0;
        outline: 0;
        list-style-type: none;
        font-size: 11px;
        line-height:42px;
        text-shadow: 0px 0px 0px #333333;
        height: 60px;
    }

I also experimented with the techniques showcased in a similar parallax demo that features a properly functioning fixed navigation bar:

Answer №1

I have made a change to the initial section by incorporating a <header> and applying the following CSS for it.

header {
    position: fixed;
    right: 0;
    left: 0;
    z-index: 1030;
    margin-bottom: 0;
    background: #FFF;
    padding: 15px 0;
}

In addition, I have introduced an offset to the first child of .parallax-container

body > .parallax-container{
    padding: 163px;
}
body > .parallax-container ~ .parallax-container{
    padding: 0;
}

Do you find this modification satisfactory? Fiddle

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

The AJAX POST request results in an error

I'm having an issue with a script that used to work but now returns a failure: function sendToServer(dataToSend) { $.ajax({ type: "POST", dataType: "json", async: false, url: "http://school.edu/myurl/write_to_mongo ...

development of MapLayers with rails and javascript

As a newcomer to RoR, I am encountering an issue that seems to be eluding me. I attempted to replicate the example application found on the mapLayers GitHub repository at https://github.com/pka/map_layers/wiki. However, all I see is the JavaScript code gen ...

Utilize the 'response.download' method to retrieve unique data not typically expected for a given request

Each time I try to download a file, the response I get is different. The file is generated correctly every time: user,first_name,last_name,active,completed_training 4,Foo,Bas,YES,YES 5,Ble,Loco,NO,NO 9,gui2,md,NO,NO 3137,foo,baz,NO,NO However, the respons ...

What is the best way to finish up the JavaScript code below?

Having just started learning JavaScript, I am struggling to figure out how to use JavaScript to clear the text in a text box and move it below the box when a user starts typing. I've been watching this tutorial http://codepen.io/ehermanson/pen/KwKWEv ...

It seems like there is an issue with the res.render function as it is

My goal is to capture an input from my main website. Once the input is submitted, the page should automatically redirect to /view. Despite successfully triggering the redirection with console.log(), the res.render function does not seem to be working as ex ...

JQuery autocomplete failing to display list items

Looking for assistance with the following jQuery code that retrieves JSON data from a server. $("#autocomplete").autocomplete({ minLength: 2, source: function(request, response){ $.ajax({ url: "data.php", ...

Create an Ajax request function to execute a PHP function, for those just starting out

I came across a JS-Jquery file that almost meets my needs. It currently calls a PHP function when a checkbox is clicked, and now I want to add another checkbox that will call a different PHP function. My initial attempt was to copy the existing function a ...

In the matrix game, if a user chooses two balls of the same color, those two matching color patterns will be eliminated

I am currently working on a matrix game with the following condition: When a user selects two balls of the same color, they will destroy the two patterns with the same color. I have successfully implemented horizontal and vertical selection. However, I ...

Using Mongoose to insert a JavaScript object directly into the database

Recently, I've been working on POSTing a JS object through AJAX to the nodejs backend. My goal is to seamlessly insert this js object into my mongoose db without having to manually map each key to the schema. This is what I have currently (a bit clun ...

The argument type 'string' does not match the parameter type 'keyof Chainable' in Cypress JavaScript

Trying to incorporate a unique custom command in Cypress (commands.js file) as follows: Cypress.Commands.add("login", (email, password) => { cy.intercept('POST', '**/auth').as('login'); cy.visit(& ...

Having trouble with downloading a node module?

I encountered an issue while trying to download the node-sass node module. The error message I received was as follows: To download the node-sass module, use the command: npm install --save-dev node-sass Error Binary has a problem: Error: \?\C: ...

Can a single-page application be created using Express without utilizing React, Angular, or similar frameworks?

Our codebase is currently exclusively built on express, and we are looking to expand it while transitioning into a single page application. At this point in time, I am hesitant to rework the code using frameworks such as Angular or React to achieve this go ...

collapse each <b-collapse> when a button is clicked (initially shown)

I am facing an issue with a series of connected b-buttons and b-collapse, all initially set to be visible (open). My goal is to hide them all when a toggle from my parent.vue component is activated - so upon clicking a button in the parent component, I wa ...

The issue of receiving a 500 error when making a POST request in node.js

I have created my own unique REST API that utilizes an NLP API internally. I need to post data on their URL, but unfortunately I am encountering an error that is causing my API to return a 500 error to the frontend. Below is a snippet of my server.js code ...

Guide to populating a dropdown list using an array in TypeScript

I'm working on a project where I have a dropdown menu in my HTML file and an array of objects in my TypeScript file that I am fetching from an API. What is the best approach for populating the dropdown with the data from the array? ...

Utilizing base64_encode versus json_encode to pass encoded data through a hidden input

I am currently working on a project where users will be able to create live blocks using Ajax. I have encoded the block's elements map inside a hidden input's value and plan to decode it within the php file. My main question is this: I am utiliz ...

Preserve page configurations upon page refresh

I'm currently in the process of creating a 'user settings' form. Each list item represents a different section, such as Updating username, Updating email, and Changing password. It looks something like this: <li> <header>Ti ...

What is the method by which the asynchronous function produces the ultimate output?

Is there a way to modify a Dojo framework-created class with an asynchronous method so that it only returns the final value instead of a Promise or any other type? ...

Changing the direction to reverse column will cause the navigation component to be hidden

Issue: The <Navigation/> components disappear when using flex-direction: column-reverse. However, if I switch to flex-direction: column, the component appears at the top of the screen and is visible. My objective is to display my <Navigation/> ...

Could this be a problem related to different domains?

My jQuery .ajax() call is working fine in IE 7 and 8, but not in FF or Chrome. I initially thought it was a cross-domain issue since it's calling across domains, but my co-worker mentioned that if it were a cross-domain problem, it wouldn't work ...