Scrolling of fixed elements within parallax elements

Encountering a problem where a fixed element (the navigation) shifts when the body element is utilized as a parallax container with the following CSS:

.parallax {
    perspective: 1px;
    height: 100vh;
    overflow-x: hidden;
     overflow-y:auto;
}

The original body element has this CSS:

html,body {
    width: 100%;
    margin: 0px;
    margin-bottom: -1.4rem;
    overflow-x: hidden;
    display: block;
    font-size: 10px;
}

And the original nav element is styled like this:

nav {
    position: fixed;
    top: 0rem;
    right: 0rem;
    height: 100%;
    /*animation*/
    transition-timing-function: all ease 0.3s;
    -webkit-transition: all ease 0.3s; /* Safari */
    transition: all ease 0.3s;
}

This issue only arises when the parallax class is added to the body element.

All of this code is within the structure of the HTML below:

<body class="parallax">
    <header></header>
    <div></div>
    <nav></nav>
</body>

Why did it cause a problem?

To clarify, there is no JavaScript involved and only the parallax container class is applied. Upon checking, the fixed position style remains on the nav element.

Here is the link to the fiddle

(On a side note, I understand that the workaround is to apply parallax to a different container and keep the nav outside that container. However, in order for iOS to shrink the URL bar, the body needs to be the scrolling element)

Answer №1

The problem arises from the inclusion of perspective through the .parallax class.

This issue cannot be resolved.

Whenever you apply transform (which is what perspective does) to an element, it serves as the reference point for any positioned children, even those with position: fixed. Consequently, your position:fixed navigation element becomes fixed in relation to the transformed parent

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

Understanding the syntax of arrays and objects in jQuery/JavaScript

I am currently working on a web page that utilizes the following syntax to generate a table using an array. Can someone provide an explanation of what {#arrayOfObjects} signifies and whether it originates from jQuery or JavaScript? {{#arrayOfObjects}} ...

Creating a dynamic video background using Html5 and CSS with a scrolling attachment

video { width: 100%; z-index: 1; position: fixed; } I tested this code and it works well, however, the video remains fixed across the entire body of the page... ...

Show various Bootstrap Alert Messages based on the type of error detected?

Trying to figure out how best to explain this, here it goes! I am working on a website and I want to incorporate alert messages. Check out some examples here. Depending on the form inputs, I need different alerts to be displayed. PHP will validate the in ...

Instructions for accessing the contents of a file that has been uploaded via the "Input Type" field in an HTML form

I have a basic HTML form with an upload field that allows users to select and upload local files. After uploading a file, the path displayed is C:/fakepath/filename.xls. I understand that this is due to browser security measures preventing direct access t ...

The CSS file is not updating

Recently, I updated an HTML file and the global CSS style sheet on my personal website. While the changes appear correctly on my computer, the website still reflects the old settings. I've taken several steps to troubleshoot this issue: Emptied my b ...

Update Symfony form class to replace the HTML5 input type from "text" to "number"

Attempting to implement an input with the "number" type for HTML5 frontend support has been a challenge. Here is my form class: class MyType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { ...

What is the best way to position a div vertically on the right side of another div?

I've been experimenting with different padding and margins to try and position the div below the dotted div. My goal is to have the div that's currently at the bottom appear vertically aligned to the right of the other div, similar to the layout ...

spacing for margins of table elements generated dynamically

Despite setting the width for the td tag, there seems to be a significant gap between the Odo and Location columns. Below is a basic table structure: <table width="95%" border="0" cellspacing="0" cellpadding="2"> <tr> <td wi ...

Issue with Modal Display in Bootstrap 5

I am experimenting with opening a modal when an image is clicked using the following code snippet: <!-- Button trigger modal --> <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target=&quo ...

Using Jquery, update the class toggle to apply to multiple span elements instead

I am facing an issue where I need to change the class of a span child using a toggle feature when clicking on a browser row. The problem arises when there are multiple rows, as the span cannot be found and the functionality does not work properly. I have ...

Shifting the final child to the front position proves unsuccessful with jQuery

I have attempted to move the last element in my list to the first position upon clicking, but unfortunately, it is not working as expected. I followed the advice provided in response to a question on the following page: Move last child to first position. W ...

What is the method for showcasing login errors and prompting users to fill in all fields simultaneously on a page with PHP?

As I develop a PHP login page, I am implementing a system where users need to enter a username and password to access the platform. One query that arises is: How can I dynamically display an 'Invalid username or password' error message on the s ...

Whenever I include __MSG_@@extension_id__ in my CSS file, I am encountering chrome://invalid

Currently, I am in the process of developing a chrome extension using Manifest V3. In my CSS file, I have incorporated the following code snippet to load local fonts. @font-face { font-family: 'PoppinsLight'; src: url('chrome-extensi ...

Insert a line below the active tab button

I made three buttons for three different tabs. Is there a way to include an underline below the active tab button (under the red "zone")? I'm aiming for something similar to mat-tab. Any assistance is appreciated! DEMO Code viewMode = 'tab ...

Change the icon switch from fas fa-lock-open to fas fa-lock by adding an event listener for a click action

let lockIcon = document.createElement("i"); lockIcon.setAttribute("class", "fas fa-lock-open"); lockIcon.setAttribute("id", color + "lock"); Is there a way to toggle between the icons fas fa-lock-open and fas fa-lock when clicking using a ...

I'm having trouble viewing my display:table-cell content because Internet Explorer is hiding it

I am attempting to align an icon vertically centered and far right inside a container. I currently have code that achieves this using ::after and table-cell properties. However, the content does not display in Internet Explorer. If I remove the display:tab ...

Selenium or Splinter: Is it possible to retrieve the current HTML page after clicking a button?

My attempt to scrape the website "" proved challenging as I discovered that the page dynamically updates. Clicking the "More" button reveals new content, but using splinter didn't automatically update the browser.html with the latest data. Is there a ...

Using Angular components to manipulate the CSS in the DOM

Struggling with dom manipulation in an angular/node.js environment using typescript for my visualcomponent.html The second inline styling works fine, showing the h1 in blue color. However, I run into issues when trying to embed strings within the innerHTM ...

Tips for adding content to a textarea after making manual changes to its existing content

One issue I encountered is with capturing the enter key on an input field and appending it to a textarea. While this works initially, any edits made directly on the textarea seem to disrupt the functionality. How can this be resolved? I have tested this i ...

Troubleshooting: Issue with detecting keypress using jQuery

Currently, I have a jQuery script that checks password strength and changes an image source based on complexity. The functionality works smoothly within jsFiddle (set to jQuery 1.91), but when implemented on my webpage, the event seems to not be triggered. ...