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

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

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

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

Tips for Incorporating HTML Code into an ASP Button's Text Attribute

How can I add a symbol to a button's text without it showing as blank? The symbol in question is an arrow, which you can find here. <asp:button id="btnAdd" runat="server" class="next"/> CSS: .next { content = &#10095; width:50px; } ...

What causes inline-blocks to malfunction after a non-breaking space is inserted?

Here is some HTML code: <p id='one'>Hello World how are you.&nbsp;<span>Entrepreneur</span></p> <p>Hello World how are you.&nbsp;<span>Entrepreneur</span></p> Below is some CSS styling: ...

Overriding Styles Set by an External CSS file

Let's assume that I have two different style sheets set up on my webpage: site.css: .modal { position: absolute; width: 200px; ... } ... reset.css: .reset * { position: static; width: auto; ... } Unfortunately, I don ...

How to easily align an image and blockquote vertically in CSS with automatic width for the blockquote

I am struggling with a layout issue involving a list of items containing images and blockquotes. My goal is to set a maximum width for the images and have the blockquotes automatically adjust their size to fit next to the images, all while keeping both ele ...

Running of code in <script> tag

At what point does the code inside script tags start executing? Does it happen in order? <html> <head> <title>Canvas tutorial</title> <script type="text/javascript"> function draw(){ var canvas = document.getElementById ...

Selenium struggles to update dropdown menu choice

Here is the HTML code snippet in isolation: <span style="position: relative; width: 100%; display: inline-block;"> <select id="0ac88542d16d6200fb983d094f655c76_select" class="form-control"> <option value="display_value">Numbe ...

The background video is not working on iPhones, even though it was functioning properly in the past

After extensive searching, I have been unable to find a solution to my issue. I used an html5 video element as a background with success on both web and mobile platforms, until recently. I have tried adding all necessary attributes for compatibility and I ...

Issues with HTML marquee not functioning properly post fadeIn()

I am attempting to create a progress bar using the HTML marquee element. When the user clicks submit, I want to fadeIn the HTML marquee and fadeOut with AJAX success. However, when I click the submit button, the marquee does not fadeIn as expected. Here is ...

My live website is plagued by an annoying horizontal scroll bar that doesn't appear in the local host version

I am struggling to remove the unwanted horizontal scroll bar on my live website, although it is not visible on my local host... <-- this is my website, built using Vite + ReactJs. I attempted to use overflow: hidden; and max-width: 100% on the body t ...

Designing an interactive region using HTML, CSS, and JavaScript

I recently created this code with some assistance: When I tried to format the code, it all ended up on one line and looked unreadable. To view the code properly, please visit this link: http://jsfiddle.net/QFF4x/ <div style="border:1px solid black;" ...

Eliminate the white background from the modal image

I'm facing an issue with an image displayed in a modal. The image has a white background that I want to remove so only the image itself is visible. https://i.stack.imgur.com/CG9Ne.png Here's the code snippet: <div id="myModal" class ...

What is the best way to display a variable (string/int) from a PHP file onto an HTML file?

I've searched online multiple times for a solution, but most of the results I found only show how to echo HTML code from a PHP file by changing the file extension to .php. However, my goal is to echo a variable from a PHP file and display it in an HTM ...

Modify information on the user interface without the need to refresh the page

Is there a way to update data on the UI without having to refresh the screen in a web application built with Node.js? I'm looking to make only specific changes on the screen. Additionally, how can I ensure that the data displayed on the screen is upda ...

Is there a way to rearrange html elements using media queries?

Here is a snippet of code showcasing how my website is structured for both desktop and mobile views. Display on Desktop <body> <div> <header> <div>example</div> <a><img src"my logo is here"/& ...

Steps to turn off the automatic completion feature for orders in WooCommerce on your WordPress website

Looking for assistance with changing the order status from completed to processing. When an order is placed, it automatically goes to completed status which is not the desired outcome. The status should change based on the virtual product purchased. I wou ...

Tips for correctly cloning a table row:

Currently, I am engaged with a Django project that involves incorporating a form within a table structure. <table name="mytable" id="table_purchase" role="grid"> <thead> <tr> <th class="text-center" hidden>No</th& ...

Creating a mandatory 'Select' component in Material UI with React JS

Is there a method to show an error message in red until a choice is selected? ...

Creating a dynamic hover drop-down navigation bar in ASP.NET

After successfully creating a navigation bar with hover effects, I am now looking to implement a dropdown list when hovering over the items. Can anyone provide guidance on how to achieve this? Below is the current code snippet I am working with: <ul c ...

Which design pattern should I implement to update all table rows except the initial one, while incorporating an AJAX insertion mode?

I am working with a table structure that is dynamic based on search results. The table consists of different rows including titles for categories like Organization, Category, and File. <table class="table-striped col-lg-12" id="results"> <tr& ...

PHP overall outcome

I have created a form that includes checkboxes, but I am facing difficulty in calculating the total result based on the selections. Ideally, if a user selects three checkboxes, the total should be $3, and if only one checkbox is selected, the total should ...