Fixed Navigation - Employing stickUp.js extension

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  padding: 0;
  font-weight: 500;
  font-family: 'Helvetica Neue', sans-serif;
}
main {} .bckgrnd {
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: 100%;
  height: 100%;
  width: 100%;
}
#break {
  clear: both;
}
div {
  width: 100%;
  margin: 0;
  padding: 0 10%;
  max-width: none;
  overflow: hidden;
}
header {
  height: 60vh;
}
#header-slide .bckgrnd {
  background-image: url("../img/headerslide.jpg");
  background-size: cover;
}
#navigation ul {
  padding: 5px 10%;
  opacity: 0.1;
  margin: 0;
  background-color: #ffffff;
  height: 6vh;
  width: 100%;
  !important
}
#navigation li {
  float: left;
  background-color: none;
  list-style: none;
}
#intro-main {
  height: 100vh;
  background-color: #373B44;
}
#mse {
  height: 100vh;
  background-color: #000000;
  background-image: url("../img/mse.jpg");
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
}
#isg {
  height: 100vh;
  background-color: #cccccc;
  background-image: url("../img/isg.jpg");
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
}
#about {
  height: 50vh;
  background-color: #A8A8A8;
}
#credits {
  height: 4vh;
  background-color: #101010;
}
<!DOCTYPE html>
<html class="no-js">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>Mse &amp; Isg</title>
  <meta name="description" content="Embroidery Ads Coveralls Signs Graphic Decals">
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />

  <link rel="stylesheet" href="css/main.css">
  <link rel="stylesheet" href="css/normalize.css">
</head>

<body>


  <main>

    <header id="header-slide" class "header">

      <div class="bckgrnd" data-center="background-position: 100% 0px;" data-top-bottom="background-position: 100% -250px;">

      </div>

      <nav id="navigation">
        <ul>
          <li>Home</li>
          <li>About Us</li>
          <li>Mse</li>
          <li>Isg</li>
          <li>Contact Us</li>
        </ul>
      </nav>

    </header>

    <div id="intro-main">
    </div>

    <div id="mse">
    </div>

    <div id="isg">
    </div>

    <div id="about">
    </div>

    <div id="credits">

    </div>


  </main>

  <script src="js/jquery.js"></script>
  <script src="js/skrollr.js"></script>
  <script src="js/stickUp.min.js"></script>

  <script type="text/javascript">
    var s = skrollr.init({
      forceHeight: false
    });

    
    jQuery(function($) {
      $(document).ready(function()

      
        $('#navigation').stickUp();
      });
    });
  </script>

</body>

</html>

Being relatively new to coding, although studying computer science in college, now is my first time applying my skills practically.

The challenge lies in a website design project for a company where most of the layout has been completed.

The issue at hand pertains to the sticky navigation bar's behavior which seems erratic, shifting to the right when scrolled down instead of sticking as intended with a consistent 100% width.

This discrepancy may be attributed to a compatibility concern between stickUp.js and skrollr, two integral plugins utilized in this web development endeavor.

To better illustrate the problem, refer to the following link:

Note that the image files are presently oversized placeholders, serving as temporary visuals until further refinement since skrollr will play a significant role in enhancing the site's aesthetics.

I appreciate any assistance offered. Thank you in advance.

Answer №1

To resolve the issue, adjust the navigation bar's width to 100% once it becomes sticky. This adjustment should correct the problem at hand.

Answer №2

When creating a sticky header, it is common practice to apply the CSS property position: fixed to it.

You can achieve this by using the following code:

.nav {
    position: fixed;
    width: 100%;
}

For a visual example, check out this CodePen demonstration:

http://codepen.io/brycesnyder/pen/dPbxqE

Answer №3

To ensure elements stick to the top and span the width of the viewport, I employ the following CSS:

position: fixed;
top: 0;
left: 0;
right: 0;

Answer №4

To address this issue, you can implement the following CSS code:

.navbar-fixed-top, .navbar-fixed-bottom {
  position: fixed;
  right: 0;
  left: 0;
  z-index: 1030;
}

Alternatively, consider utilizing a Bootstrap plugin to enhance the layout of your website. Here is a helpful link to the Bootstrap plugin along with an example: Bootstrap Plugin Example

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

Effective approach for managing a series of lengthy API requests

I am developing a user interface for uploading a list of users including their email and name into my database. After the upload process is complete, each user will also receive an email notification. The backend API responsible for this task is created u ...

assigning a variable using jQuery

<script> function update(elem) { var ele=$(elem).siblings('label#test').html(); var a=document.getElementById('test'); var htm = '<input type="text" name="modal" id="modal" style="width:70%;" value="'+$(elem).siblings ...

Toggle the visibility of an element with a single button click

Below is a snippet of my sample code: SAMPLE HTML CODE: <ul> <li class="item"> item 1 </li> <li class="item"> item 1 </li> <li class="item"> item 1 </li> <li class="item"> item 1 </li> <l ...

How can I combine jQuery UI Themeroller with my own custom jQuery UI widget?

I am reaping the advantages of Themeroller in conjunction with the standard widgets provided by jQuery UI. The part that perplexes me is integrating Themeroller with a custom widget built on top of the jQuery UI widget factory. This excerpt from the help ...

Is MongoDB's find() method returning incorrect objects?

My current task involves running a Mongo query on the Order database to retrieve orders associated with a specific user by using their email. This process is achieved through an API, but I'm encountering difficulties as the returned object contains un ...

Fade in elements as the cursor moves, without hovering over a specific element

I'm working on implementing a fade-in effect for content when the mouse moves (similar to Google's homepage), but I'd like to avoid this behavior if the cursor is hovering over a specific div. Here are the basics: $("html").hover(function( ...

Utilize the <a> element as a button to submit the data form

I am looking to transfer data from a form to another PHP page without using a button within the form itself. Instead, I have placed a separate button outside of the form for submission. How can I achieve this by sending the form data to the other page? Bel ...

The Ajax/jQuery output is not showing up in the iframe, but is instead appearing on a separate page

I've scoured various forums and websites, attempting to troubleshoot the issue described below without success. This problem persists in both IE 11 and Firefox 10.0.2. My goal is to submit a form (POST) to a website () and showcase the resulting bri ...

What is the best way to access the next-auth session using getStaticPaths and getStaticProps in dynamic routing scenarios?

I am currently working on implementing dynamic routing in a NextJS application. I need to retrieve the token from next-auth in order to make axios requests to an API and fetch data from getReport and getReports (located in /reports.js). However, I am facin ...

Strange HTML pop-up keeps appearing every time I use styles in my code or insert anything with CSS

Recently, I created an OctoberCMS backend setup through my cPanel (I also have one on my localhost). Now, I am trying to add a background image but every time I attempt to do so, a strange HTML popup appears that I can't seem to figure out. Here is th ...

The previous button on Owl Carousel seems to be malfunctioning after navigating from a different page

In my case, I have two distinct pages: let's call them the first and second pages. On the first page, I utilize an owl carousel slider with a tag that links to a specific slide on the second page's owl carousel slider using an ID. Meanwhile, on ...

Content displayed in the center of a modal

Struggling to center the captcha when clicking the submit button. Check out the provided jsfiddle for more details. https://jsfiddle.net/rzant4kb/ <script src="https://cdn.jsdelivr.net/npm/@popperjs/<a href="/cdn-cgi/l/email-protection" class=" ...

Step by step guide on inserting a message (memo/sticky note) onto an HTML page

Wondering how to accomplish this: I've designed an HTML5 homepage and I'm looking to display a message to visitors, such as "Dear visitor, I am currently on vacation from....", in the form of a memo or sticky note positioned in the top right cor ...

firefox compatibility issues with jquery ajax

Trying to establish a connection with a URL and expecting a large object in response has proven to be challenging. The process appears to function smoothly until an error occurs during the return reply, triggering the .ajax.error() function. Unfortunately, ...

The data list is failing to retain previous elements as new ones are incorporated

I have a list for uploads, and whenever I upload new data, the old data in the list gets removed. However, I want to display all the data together. How can I resolve this issue? const [fileList, setFileList] = useState<AddedFile[]>([]); const beg ...

What is the best way to utilize the history prop in conjunction with other props?

I am currently using react-router-dom along with react. My goal is to include additional props along with the history prop import React from 'react'; function MyComponent({ history }) { function redirect() { history.push('/path&ap ...

View the image without needing to upload it

Can you display an image from an input type="file" on a page without actually uploading it to the server? Is there a way to copy the image into a location that the script can access in order to achieve this? It doesn't matter if it loads after a refr ...

Unable to create a new collection in Firebase Firestore

I encountered an issue while trying to add a collection in Firebase Firestore using the function .collection(doc).set. Despite finding the new user in authentication in Firebase, the collection was not created and the console displayed an error message. ...

Can a package-lock.json file be created without running an npm install command?

Is there a way to create only a package-lock.json file without having to redo the npm install process? I'm looking to generate the lock file without reinstalling any of the package files. Is this achievable? ...

Confirm that the input into the text box consists of three-digit numbers separated by commas

Customers keep entering 5 digit zip codes instead of 3 digit area codes in the telephone area code textbox on my registration form. I need a jQuery or JavaScript function to validate that the entry is in ###,###,###,### format without any limit. Any sugge ...