Trouble with z-index | initial div out of four malfunctioning

Currently, I am attempting to practice by replicating the design shown in this image:

https://i.sstatic.net/iIA2q.jpg

However, I have encountered an issue that has been persisting for some time:

https://i.sstatic.net/grABz.png

I'm struggling to understand why this issue is occurring. An interesting observation is that if I remove the first div, the second div (which then becomes the first) experiences the exact same problem. Furthermore, all four divs share identical CSS properties except for z-index, so why does only the first div exhibit this behavior?

Below is a shortened version of my HTML code:

<div class="row">
    <!-- Card #1 -->
    <div class="col-md-3">
      <div class="card-container first-card">
        <div class="card-component">
          <a href="#">
            <div class="front">
              <img src="img/img-presentation1.jpg" alt="" />
            </div>
          </a>
        </div>
      </div>
    </div>
    <!-- Card #2 -->
    <div class="col-md-3">
      <div class="card-container second-card">
        <div class="card-component">
          <a href="#">
            <div class="front">
              <img src="img/img-presentation1.jpg" alt="" />
            </div>
          </a>
        </div>
      </div>
    </div> 
</div>

<div class="row bg-grey">

And here is the corresponding CSS:

#sliding-cards .card-container {
  perspective: 900px;
  width: 300px;
  position: relative;
  margin-top: 90px;
}

#sliding-cards .card-component{
  transform-style: preserve-3d;
  position: relative;
  height: 500px;
}

#sliding-cards .front {
   transform: rotateY(-35deg);
   position: absolute;
   top: 0;
   left: 0;
   width: 100%;
   border-radius: 10px;
   overflow: hidden;
}

#sliding-cards img{
  vertical-align: middle !important;
  border-style: none;
  width: 100%;
  z-index: 2;
  position: relative;
  max-width: 100%;

}

The cards are assigned z-index values of 6, 5, 4, and 3 respectively, while the div beneath them (with the grey background) has a z-index of 7;

JSFiddle

Thank you to everyone who can provide assistance with this issue!

Answer №1

To resolve this issue, simply include the following code: z-index: -999999 for the .front class.

html,
body {
  overflow-x: hidden;
  height: 100%;
  font-family: 'Poppins', sans-serif;
  background: #333;
}

#sliding-cards .section-components {
  background: black;
  padding: 70px 0;
  z-index: 1;
  color: #FFFFFF;
  position: relative;
}
...
            ...
                           ...
                                                       ...
 <section id="sliding-cards" class="bg-dark-red py-5">
   <div class="section-components">
     <div class="container">
     
       <div class="row"></div>
       
      ...
                            ...
                                 <!-- Card #4 -->
                                ...
                                   ...
                                         /* End of Code Snippet */
                                             

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

Custom CSS file for individual tenants in the Twig main template

Our Symfony 2.4 application is a multi-tenant system, meaning we share the same codebase among several organizations and differentiate access by domain name. For example: organization1.domain.com organization2.domain.com organization3.domain.com We util ...

Despite being a valid <link rel="shortcut icon">, a validation error occurs

I'm encountering an error with the w3.org validator related to this line of code: <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" /> The error message provided is as follows: Line 1, Column 727: Invalid value shortcut icon f ...

Implementing Materialize CSS functionality for deleting chips

I've been attempting to extract the tag of a deleted chip from the div within the Materialize chips class, but I'm hitting roadblocks. My failed attempts so far: $('.chips').on('chip.delete', function(e, chip){ console.lo ...

Is there a foolproof method to verify if a user truly has visibility of a div element?

When I search online, most solutions only consider the viewport and/or the first parent container that is scrollable when trying to determine if a div is visible. However, I am wondering if there is a foolproof method to check if a div is truly visible t ...

The output of new Date() varies between app.js and ejs

app.get("/test",function(req,res){ var d = new Date(); res.send(d); }); When I access mydomain/test, it displays the output "2019-03-19T04:50:47.710Z" which is in UTC. app.get("/testejs",function(req,res){ res.render("testejs");}); Below is the content ...

Scroll positioning determines the height of an entity

Here's a code snippet I'm working with: HTML: <div id="wrap"> <div id="column"></div> </div> CSS: #wrap { display: block; height: 2000px; width: 400px } #column { display: block; height: 20px; ...

HTML Element Split in Two by a Line in the Middle

Greetings to all, after observing for a while I have decided to make my first post here (and just to clarify, I am an electrical engineer, not a programmer). I am in search of creating a unique element in HTML where I can detect clicks on both its upper a ...

Using jQuery to establish a canvas element and define its dimensions by adjusting its width and height attributes

My attempt at using jQuery to create a canvas element was not quite as expected. Here is the code I tried: var newCanvas = $('<canvas/>',{'width':100,'height':200,'class':'radHuh'}); $(body).append(n ...

CSS technique to display background on hover

My website has a bootstrap 'More' dropdown feature on the left navigation bar. However, there is an unwanted background hover effect that I can't seem to remove. Despite removing all background hovers from my CSS, the issue persists. Can any ...

Looking for assistance in using JavaScript to determine the percentage of a DIV's width in pixels

Using PHP, I am generating boxes whose width is set to 100% of a container in CSS. Now, I want to determine the equivalent pixel value of that box... HTML <div class="masonry" > <? while($row = $stmt->fetch()){ ?> <div class="i ...

Is there a way to attach a CSS class to a BoundField in order to locate it using jQuery?

I need to assign a specific class name to certain BoundFields within the GridView control. This way, after the GridView has been populated with data and displayed, I would like to have something similar to the following: <td class="Tag1">Some data c ...

Unable to assign a value to a variable in JavaScript

Today, I delved into the world of JavaScript and decided to test my skills by creating a page that changes images when clicking on a div. Everything worked perfectly until I wanted to add an input element to specify how many steps to jump each time the but ...

What is the best way to incorporate parallax scrolling in the center of a webpage?

I am trying to implement a parallax scrolling effect in the middle of my page, but it seems to be causing issues once I reach that section while scrolling. I attempted to use intersection observer, but unfortunately, it did not resolve the problem. const ...

Uploading Multiple Files Using HTML5 and AJAX

I recently stumbled upon this simple plain JavaScript AJAX upload code (apparently jQuery's $.post doesn't work properly with HTML5 for some reason), /* If you want to upload only a file along with arbitrary data that is not in the fo ...

Is all of the CSS stored in one or multiple files?

Will the number of CSS files on my website impact its performance? I understand the necessity of having a separate file for print styles, but I'm wondering about the other CSS files. Is it better to have all my styles in one file or split them into mu ...

svg viewbox cannot be adjusted in size

Struggling with resizing an SVG to 20px by 20px. The original code size of the SVG is quite large at 0 0 35.41 35.61: <!doctype html> <html> <head> <meta charset="utf-8"> <title>SVG</title> ...

Simple way to extract the values from every input element within a specific <tr> tag using JQuery

Is there a way to align all input elements in a single row within my form? For example, consider the snippet of code provided below, which includes a checkbox and a text input box. I would like to retrieve the values from both of these input types and pres ...

Gap in footer spacing on Internet Explorer is significantly large

The layout of the page is split into two main sections: A large header that takes up 100% of the browser height The main content area and footer When viewing the page in a browser, only one of these sections will be visible. The following code works wel ...

Steps for encoding a CSV export with HTML:

When I retrieve data from a string that is HTML encoded as Quattrode® I end up with Quattrode® after viewing it in Excel 2007. Here is the routine: Response.Clear(); Response.Buffer = true; Response.ContentType = "text/ ...

Ion-List seamlessly integrates with both ion-tabs and ion-nav components, creating a cohesive and dynamic user interface

On my homepage, there is an ion-list. Sometimes (not every time), when I select an item in this list or navigate to the register page using "this.app.getRootNav().push("ClienteCadastroPage")", and then select an input in the registerPage or descriptionPage ...