Strange display glitch in desktop webkit browsers (Safari/Chrome) when using absolutely positioned elements

If you check out the video linked here: , you'll witness the issue in action. Essentially, my code structure resembles the following:

<section id="sidenav">
  <h1>TEXT HERE</h1>
  <ul>
    <li>Tab One</li>
    <li>Tab Two</li>
    <li>Tab Three</li>
    <li>Tab Four</li>
  </ul>
  <div id="tab"></div>
</section>

The sidenav is positioned absolutely as shown below:

#sidenav {
  position: absolute;
  top: 200px;
  left: 0px;
  width: 770px;
  padding: 30px 0px 20px;
  background: rgba(255, 255, 255, 0.85);
  -webkit-transition: left 0.75s ease-in-out;
  -webkit-backface-visibility: hidden;
  z-index: 10; /* This fixed it. */
}

#sidenav.hidden {
  left: -768px;
}

I've also incorporated the following jQuery script:

$("#tab").click(function(){
  $("#sidenav").toggleClass("hidden");
});

However, during the animation, the elements within the section don't synchronize properly. They tend to lag or stay stationary when the toggle occurs. Although they appear inactive, I can't interact with them. The elements usually catch up once the side nav reemerges, but sometimes they remain glitchy until I hover over the <li>'s.

Please note that this issue only arises in Safari and Chrome on desktop devices. Safari on iPad and Firefox operate without any problems.

Thank you! Andrew


FIX EDIT:

After adding a z-index of 10 (or any value) to the sidenav element, the problem was resolved. Some individuals requested my entire CSS code, which I included in this post. While I'm uncertain why adjusting the z-index rectified the issue, I'm eager to understand the reasoning behind it. I am still offering my reward to whoever provides an explanation. Thank you!

Answer №1

After some experimentation, I found that adding a z-index of 10 to the sidenav element resolved the issue at hand. In response to inquiries about my complete CSS code, I have updated the post accordingly. The underlying reason why z-index solved this problem remains unclear to me, and I am eager to gain insights on that. My bounty reward still stands for anyone who can provide a satisfactory explanation. Thank you!

Answer №2

Due to my newness here, I would rather post this as an answer instead of a comment. In the video example you shared, hovering over the list elements displayed arrows that did not disappear when the mouse was moved away. To achieve this effect using only CSS and avoid leftover images, utilize the hover property.

You can find more information in this post: Using only CSS, show div on hover over <a>

This method ensures that the arrows will not linger after the list element slides off the page to the left by hiding them when the mouse leaves.

Answer №3

There are occasions when this strategy proves successful: setting the parent element's position:relative is akin to addressing webkit's interpretation of the long-gone ie haslayout issue.

Answer №4

Based on the provided markup, it appears that the class "hidden" will also affect your 'nav' div since it is inside sidenav - this could potentially lead to some unexpected behavior.

As a general guideline:

  • Start by marking up the content
  • Then style it up
  • Add interactions (such as click events and behaviors)
  • Lastly, add any final interaction enhancements (like easing effects, etc.)

(By following these steps, you can pinpoint which part of the UI is causing issues)

Answer №5

I successfully resolved the issue by eliminating the z-index property from the parent element and assigning a z-index value greater than 0 to the fixed element. Hopefully, this solution proves helpful for others facing similar challenges.

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

How to show specific images by clicking on particular items in Ionic 3 on a separate page

Can someone assist me with displaying specific images from a slider gallery? I am struggling to figure out how to show only the January edition when clicking on it in eighteen.html, while hiding the February and March editions. It has been 2 days of unsucc ...

Showing specific XML data from a node when a button is clicked in an HTML document

<script> $(document).ready(function(){ $.ajax({ type: "GET", url: "data.xml", dataType: "xml", success: function(xmlData) { $("POS", xmlData).each(function(){ var sr = $(this).find(&apos ...

Engage in a Play app featuring AngularJS frontend navigation

Currently, I am using the Play Framework to develop a REST service and I would like the front end to be built with Angularjs in order to make rest calls. I have configured a route provider as follows: angular.module("getAbscencePlans", ["getAbscencePlans. ...

Each Vue instance on the page has its own isolated Vuex store

I have a situation where I am creating multiple Vue apps on the same page: import Vue from "vue"; import App from "./App.vue"; import useStore from "./store"; const arr = [1, 2]; for (const index of arr) { const store = use ...

Necessary elements for communicating with an HTML form on the web

To fully comprehend the question, please take a look at the linked page below. Is there a method to identify the text input field for city/state/zip on the mentioned website? I am in need of allowing users to input city, state or zip into my own text fie ...

A webpage styled with w3.css featuring text without any underline

I am currently using w3.css but I'm facing an issue where some of my hyperlinks have underlines while others do not. My goal is to remove all underlines from the hyperlinks in the content below: <ul class="w3-ul w3-white"> <a class="" href=" ...

Exploring the functionality of the JQuery Chained plugin for bidirectional chaining

Let's tackle a simple problem involving car brands and models. Take the example below: <select id="brand"> <option value="">Choose</option> <option value="audi" class="a1 a3 a4">Audi</option> <option value ...

Struggling to make $.ajax.mostRecentCall function properly in jasmine 2.0.2

Struggling to make a basic example work properly. I found this code snippet on https://gist.github.com/Madhuka/7854709 describe("Check for spies", function() { function callFunction(callbacks, configuration) { $.ajax({ url: configurat ...

Performing a single search, making changes, and executing the operation

I'm a bit lost on how to properly utilize mongoose based on the documentation. The documentation suggests that using findOne().update().exec() should result in a promise, but what is actually returned doesn't include a fail member: var ret = mon ...

A guide on implementing multiple submit buttons within a react.js form

My goal is to develop a form using react.js that allows users to perform two different actions by clicking on separate buttons. Specifically, the form should enable users to select a document and decide whether they want to replace the current document (1s ...

Implementing image display in autocomplete feature using jQuery

I am currently working on a project using Spring MVC, where I am implementing a jQuery autocomplete plugin to fetch data from a JSON file generated by the server. $('#searchTerm').autocomplete({ serviceUrl: '${ctx}/search/searchAutocomp ...

Guide on including a partial view in a modal using Jquery

Looking to enhance the parameters of a list of products by displaying a modal window for editing? You can achieve this by including a button in each row that triggers the modal window... https://i.sstatic.net/kDw6q.png The Edit button code in Index.csht ...

Are the orders of events maintained when emitted using an event emitter?

I have a simple query regarding the event emitter, which is crucial for my program's logic. Currently, I am utilizing an external library that triggers events that I'm listening to. These events consist of 'data' and 'error'. ...

Vibrant diversity in a solitary symbol

I have customized styles to incorporate Fontawesome icons with their brand colors - for instance, the Opera icon appears in red, IE in blue, and Firefox in orange. Chrome, however, presents a unique challenge with its four distinctive colors. I am curious ...

Obtain the URL value by utilizing jQuery

I came across a helpful tutorial from Codrops on customizing a drop-down list, specifically the example provided. I simply copied and pasted the markup and jQuery code and then tailored it to my own style. However, upon examining the example closely, I no ...

Unusual margin that demands attention!

I'm currently in the process of designing a website and have just started working on the header section. However, I've encountered an issue where there is an unexpected 28px margin at the top. Upon inspecting the code, I found the culprit: medi ...

Suggestions for improving my jQuery Ajax implementation

On my website, users can post comments on two different things: a user's profile and an app. Initially coded in PHP, we later decided to incorporate Ajax for a more stylish effect. The comment now smoothly fades into the page and functions properly. ...

Are you experiencing difficulties with coding text emails?

I am currently in the process of sending an email with an attached PDF file. Here is the code snippet I am using: $mpdf->WriteHTML($html); $content = $mpdf->Output('', 'S'); $content = chunk_split(base64_encode($content)); $ ...

How to fetch elements from an array using EJS and MongoDb

Overview: I'm currently working on a project using Node, Express, MongoDB, and EJS for templating. The backend code seems to be in good shape as I've tested it using PostMan. However, I'm facing issues with the frontend part. When attempti ...

Transfer the document into JavaScript by copying and pasting

I am in need of some assistance with a basic form that includes an input field. While the form is functional, I would like to provide users with the option to upload a file by simply pasting it into the browser using CTRL+V. Is there a way to achieve this ...