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

Is there a way to prevent EasyTabs from automatically selecting the second tab?

I'm facing an issue with setting the default tab using easytabs. Currently, the second option is automatically selected as the default tab. Previously, I had successfully set the first tab (statistics) as the active tab but lost the file. Now, I am s ...

The enigmatic appearance of CSS border-image using a transparent image creates a visible edge when viewed

My website, located at , features a unique design element created using the CSS border-image property and a .png image with a transparent edge, giving the appearance of torn paper on the divs. However, I have encountered an issue specifically on my Android ...

Press the "Print All" button to instantly print out all of the images in one go

I have successfully implemented a feature where multiple images are displayed as thumbnails from a specified folder. Now, I am looking to add a "Print All" button that will allow users to print all the images in one go. Is it possible to print all images ...

Issue with JQuery event handlers becoming unresponsive upon resizing the window

JSBin link: http://jsbin.com/4QLDC/6 Here is the JS code snippet that I have written: var toggleContent = function (event) { $(event.target).siblings().toggle(); }; var showOrHidePanels = function () { var windowHeight = $(window).height(); v ...

Various placements in Internet Explorer, Chrome, and Mozilla Firefox

Currently, I am working on a website project The layout appears to be fine in Internet Explorer and Firefox, but there seems to be an issue in Chrome. Due to the length of the code, it cannot be posted here, so I have included links to the files: HTML: ...

Restrict the dimensions of the image to fit within the div

I've been struggling to resize my LinkedIn logo on my website. I've attempted various methods, like using inherit and setting max height and width to 100%, but the logo keeps displaying at full size. Do I need to use a different type of containe ...

Tips on Updating Array Value with jQuery

I have been working on using jQuery to edit array values. Here is my approach: From a modal, each time I click the "Add item" button, it pushes values to an array and appends the data to a table. var iteminfo = { "row": 'row' + cnt, "ma ...

Align title text to the right within the Material Design Card

I have implemented a Material Design (MDL) card to showcase numeric values in the title. However, I am facing an issue where the values are left aligned by default and I want them to be right aligned. Despite trying various styles, they are being ignored ...

When the Chrome Dev Tools are activated, the responsive website malfunctions

As I work on designing a responsive website, I've encountered an issue with media queries. When I set the breakpoint to min-width: 320px in Chrome dev tools, all of my CSS styles disappear. The same problem occurs when I zoom the window size to 150%, ...

Adjusting the color of a specific part of a text within a string using

I am trying to update the color of specific keywords within a post. For example: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam tempor lacinia urna eget gravida. Quisque magna nulla, fermentum fermentum od #keyword1 #keyword2 #keyword3 ...

Having trouble with my phonegap app not allowing me to open any

I've just embarked on creating my first phonegap application using an HTML5 mobile website template. After deploying it, I noticed that the external links are not working within the app. Clicking on a link doesn't seem to do anything. To addres ...

Preventing the selection of 'None selected' upon dropdown change

When using the NameTextBox Dropdown, all names are available for selection. Upon changing a name and clicking on search, the associated details are retrieved. However, by default, 'None Selected' is displayed. Is there a way to prevent 'None ...

Determine the total by multiplying the value of a dropdown menu and a text input field using jQuery when the values are changed

I am new to jQuery and JavaScript. I have a textbox and a select box, and when I enter a value in the textbox and select a value from the select box, I want to display the multiplication of both values in another textbox. I have tried doing this with two t ...

HTML needs to be wrapped around every set of three items using C# ForEach loop

Currently, I am faced with the task of constructing an HTML code structure within C# code behind. Specifically, I need to insert an HTML element that spans 3 columns in a row of 12 columns (utilizing Zurb Foundation). To achieve this, I am iterating throu ...

The images fail to load on Mozilla browser and appear as blank spaces

My images are only displaying as white in Mozilla but fine on other browsers. I've tried using -moz without success. It's a simple fix that I can't seem to locate. Any help would be appreciated. Just a quick note, the images appear blank wh ...

Creating an inverted curve or border-radius for a div element is a design technique that can add

I've been tackling a project that requires me to style the border of a div in an inverted manner. To achieve this, I'm limited to using only CSS and JS without any plugins. I've searched through various online resources and similar questions ...

Perhaps dividing numbers with regular expressions

My HTML textarea allows users to input numeric serial numbers in various formats - either inline, separated by any character, or in columns from an Excel file. The serial codes are either 14 characters long if the first character is "1," or always 15 char ...

Can you explain the distinction between using .hover and :hover?

Recently, I came across some CSS code that was written by someone else and it contained the following: li.hover, li:hover { } This made me curious - is there a distinction between .hover and :hover in CSS? Could it be possible that certain browsers inte ...

What steps should I take to adjust the price when multiple items are chosen?

I am working on a school project that requires JavaScript programming assistance. You can view the code here: https://jsfiddle.net/zvov1jpr/3/ HTML: <script src="java.js"></script> <div id="formular"> <div id=&qu ...

Creating a loading screen in Angular2: Step-by-step guide

How can you best integrate a preloader in Angular 2? ...