What is causing all webkit browsers to overlook the z-index in my code?

I have removed all unnecessary elements from my webpage to focus on reproducing a specific issue.


HTML:

<html lang="en-us">
    <head>
        <meta charset="utf-8" />

        <meta name="viewport" content="width=device-width, initial-scale=1" />

        <title>Home | Minimal</title>

        <link rel="stylesheet" href="~/Shared/Assets/Stylesheets/Core.css" />
        <link rel="stylesheet" href="~/Shared/Assets/Stylesheets/Home.css" />
    </head>
    <body>
        <header>
            <img id="key" src="~/Shared/Assets/Images/Icons/K.png" alt="Sign In | Create an Account" />
            <img id="logo" src="~/Shared/Assets/Images/Logos/JWLSS.png" alt="Minimal" />
        </header>
        <div id="main">
            <footer>
                <p style="margin-top: 100px; text-align: center; color: white;">&copy; Minimal 2015</p>
            </footer>
        </div>
    </body>
</html>

CSS:

* {
    margin: 0;
    padding: 0;
    outline: none;
    border: none;

    font-family: 'Segoe UI Light', Tahoma, Geneva, Verdana, sans-serif;
}

html, body
{
    width: 100%;
    height: 100%;
    overflow: hidden;

    background-image: url('../Images/Backgrounds/JWSSB.jpg');
    background-repeat: no-repeat;
    background-size: cover;

    background-position-y: 50%;
}

header
{
    width: 100%;
    height: 50%;

    background-color: #2695D7;

    opacity: 0.90;
}

#main
{
    height: 50%;
    background-color: white;
    opacity: 0.90;

    border-top: 0.1px solid white;
    padding-top: 5%;

    position: relative;
}

#key
{
    float: right;
}

#logo
{
    text-align: center;
    margin: 0 auto;
    position: absolute;
    right: calc(100% / 2 - 176px / 2);
    bottom: calc(100% / 2 - 100px / 2);
    z-index: 1000;
}

#sections
{
    width: 50%;
    height: auto;
    margin: 0 auto;
}

.section
{
    width: calc(100% / 3);
    height: auto;
    float: left;
    text-align: center;
    font-size: 10pt;
}

The issue is with the positioning of the logo element in relation to other sections of the page. The logo should be displayed above all other elements but fails to do so in certain browsers.

Attempts to resolve this include adding position: relative; to parent elements and avoiding negative z-index values, but these have not solved the problem.

If you have any suggestions on how to make the absolutely-positioned logo appear above everything else, please let me know.

Answer №1

To ensure the logo is displayed above the header element, you must adjust the position of the header.

header{
  position: relative;
  z-index: 99999;
}

Due to the stacking order, the logo cannot be positioned above the header if both elements have the same stacking order. Therefore, it's essential to assign a higher stacking order to the header element compared to other elements, such as setting it to 2 if the main element is set to 1. This way, the header will be in an upper layer than the main layer.

I hope this explanation clarifies things for you!

One effective method is to nest your header element within the main element to easily manage the z-index levels.

While implementing this solution may not be ideal from a semantic standpoint, it addresses the issue at hand effectively.

Answer №2

Within the header lies the logo, which is not included in the layer stack. To properly position it, you must apply relative positioning to the header and assign it a z-index. Any other elements within the header, aside from the logo, should also be given the same z-index.

Answer №3

For Safari and other webkit browsers, it is recommended to include transform: translate3d(0,0,0); for elements with a relative position.

The reason behind this requirement remains unclear, but I faced significant difficulties until I implemented this solution.

Here are some prefixes to consider for the transform property:

-ms-transform: translate3d(0,0,0); /* IE 9 */
-webkit-transform: translate3d(0,0,0); /* Chrome, Safari, Opera */
transform: translate3d(0,0,0);

Check out the following website for an example: www.meineluftaufnahme.de

I previously had to utilize transform on that site, specifically on elements with a position: relative;.

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

Adjust the position of the element by lifting it slightly

I am looking to adjust the positioning of the number "01 / 04" to match the layout shown in this image: Here is what I have accomplished so far: This is how the code structure looks like in vue js at the moment: <img id="theZoomImage" sizes="100vw" : ...

Dynamic script appending encounters unforeseen challenges

After attempting to add a script either on click or after a time delay, I am encountering an issue where the script is not being appended. Strangely, if I remove the setTimeout function, the script gets added successfully. The same problem persists with ...

What is the formula to determine the precise hue-rotate needed for producing a particular shade?

I'm looking to change the color of a white background image in a div to match the main theme color. I know I can use filters like sepia(), saturate(10000%), and hue-rotate() to achieve this, but is there a way to calculate these values beforehand? Sin ...

Maintaining Image Aspect Ratio within a Div with a Specified %width

Apologies for the repeated question, but my research hasn't yielded a solution I can apply. Inside a div with the specified styles, there is an image: <div class="thumb grid_6"> <img src="img/test2.jpg" alt="flavin" /> </div> . ...

Highcharts plots only appear once the browser window is adjusted

Having some issues while testing out the Highcharts javascript charting library on a specific page. The problem I'm encountering is that none of the data appears until I adjust the browser's size slightly. Prior to resizing, the tooltip does dis ...

Execute a jQuery focus() function on a textarea element within a dynamically added form on the webpage

Whenever I dynamically insert a new form onto the page using clone(), my goal is to have the textarea within the form automatically focused. However, despite trying out the code below, it seems like it's not functioning as expected: .on('click&a ...

Issue with overlay functionality after updating to jQuery version 1.12.1

Hey there! I'm currently in the process of upgrading my web application system's jQuery to version 1.12.1 and I've run into an issue with the overlay not functioning properly in the new jQuery version. My setup involves using ajax to displ ...

Is your email showing up with an unknown sender when using the display function?

I'm facing an issue where the name entered in the input field on a contact form is not being displayed after submitting the email. The headers in PHP were changed and now it shows "unknown sender" instead of the name that was entered. How can I fix th ...

Having issues with Drupal's lightframe and lightbox functionalities not functioning properly

I recently came across a Drupal 6 project that I have little knowledge about. My goal is to incorporate an Iframe into a lightbox, which seems simple but I'm encountering some obstacles. Despite researching online and attempting to implement the code ...

Enhancing User Interaction: Tips for Focusing on Touch in React Input Text Field

Having a bit of an issue with my input component that works perfectly on desktop but seems to be malfunctioning on mobile. I can't seem to get it to focus on press, and all the solutions I'm finding are related to React Native which I'm not ...

Alter the hue of a component upon being clicked

Seeking help to modify the color of my menu elements upon clicking on the "center" or "right" containers (reverting back when clicked again). Currently, the three lines in my menu are white, but I desire them to turn red when either of these containers is ...

Is it possible to extract form data from a div tag based on its class name?

I'm working with some code that looks like this: var iconContainer = document.getElementById('iconContainer'); var icon = iconContainer.getElementsByClassName("item"); for (var i = 0; i < icon.length; i++) { icon[i].addEventListener ...

employing the CSS `:empty` pseudo-class to conceal an element

Upon using chrome for inspection, I stumbled upon the following code snippet: <div class="entry-content"> <p>We .... </p> </div> <footer class="entry-footer"> </footer> Occasionally, this f ...

no visible text displayed within an input-label field

Currently, I have started working on a multi-step form that is designed to be very simple and clean. However, I am facing an issue where nothing is being displayed when I click on the next arrow. I am puzzled as to why it's not even displaying the te ...

What could be the reason for the state not initializing with the provided value?

It seems that the latest value is being passed through props, but when it is set as the initial value for state, it doesn't appear. https://i.stack.imgur.com/7dVf2.png import React, { useRef, useState } from "react"; //importing config fr ...

Issue with overflow in TailwindCSS design

I'm working on implementing a unique layout using Tailwind CSS for a dashboard. The height of the initial view should match the screen size and remain within those limits at all times. Initially, the blue section of the dashboard will be empty (but ...

"Tagging multiple content snippets within a label element to create a truncated text

How can I truncate a specific inner span of a label, containing multiple span elements, to prevent overflow into the next line? To address this issue, I have created a JSFiddle available at https://jsfiddle.net/keltik/k18892xe/3/. Here is a snippet of the ...

Having trouble with the Ng multiselect dropdown displaying empty options?

I'm currently facing a challenge in adding a multiselect dropdown feature to my project. Below is the code I have been working on: HTML <ng-multiselect-dropdown [settings]="searchSettings" [data]="dummyList" multiple> </n ...

What is the method for including preset text within a search bar?

My current issue is as follows: When the searchbox is focused, it appears like this: -------------------- -------------------- Upon exiting the searchbox, a string will automatically be added to it: -------------------- Search -------------------- I a ...

Show the chosen item from a dropdown menu using Bootstrap

Here is the HTML code that I am working with: <!DOCTYPE html> <html> <head> <title>Bootstrap Example</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="h ...