Difficulty arises with z-index when hover effects are applied to clip-path shapes

I'm encountering an issue where I am attempting to make two clip path polygons overlap each other when hovered over by the mouse. I have been using z-index values and trying to adjust them based on which overlay is being hovered over, but unfortunately, it seems like my efforts are not yielding the desired outcome. I attempted changing the z-index when the object is hovered over, but it does not appear to be making any difference.

.banner {
position:relative;
    bottom 0;
    top: 0;
    left:0;
    right: 0;
    width: 100%;
    height: 700px;
}

.overlayleft {
position:absolute;
    z-index:1;
    bottom 0;
    top: 0;
    left:0;
    right: 0;
    width: 50%;
    height: 100%;
    overflow:hidden;
    clip-path: polygon(0 0, 75% 0, 100% 100%, 0% 100%);
    background: rgba(0,0,0,1);
    transition: .5s ease;
}

.overlayright {
position:absolute;
    z-index:2;
    bottom: 0;
    top 0;
    left: 50%;
    right: 0;
    width: 50%;
    height: 100%;
    overflow:hidden;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 25% 100%);
    background: rgba(0,0,0,0.6);
    transition: .5s ease;

}

.overlayleft:hover{
z-index: 4;
  width: 100%;
}

.overlayright:hover{
z-index: 4;
  width: 100%;
  left: 0;
}
<!DOCTYPE html>
<html>
  <body>
    <div class="banner">
      <div class="overlayright"></div>  
      <div class="overlayleft"></div>
    </div>
  </body>
</html> 

Answer №1

It is due to the use of "background: rgba(0,0,0,0.6);" in the CSS style.

The opacity gives the color a transparent effect. If you were to change the color to red, for example, you would notice a significant difference.

The first div appears black while the second div appears gray. When the gray div is hovered over, it may not be immediately obvious that it is overlapping the black div due to its transparency...

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

Can a specific CSS rule be written in Material UI using makeStyles that will only apply if the element has both classes together?

It's common knowledge that achieving this in CSS is a possibility. .makeStyles-mainNavWrapper-67.sticky{ position: fixed; top: 0px; opacity: 1; transition: opacity 1s ease; padding: 10px; } I am curious to find out if this can be achieved ...

Creating rounded corners in Firefox can result in a gap between the border and the background

I'm trying to round the corners of a div, but in Firefox there seems to be an issue with whitespace between the border and background color. Check out my demo fiddle. <div>&nbsp;</div> div { margin: 20px; width: 250px; ...

Graphs vanish when they are displayed in concealed sections

Looking for a way to toggle between two charts (created with charts.js) by clicking a button? Initially, I had them in separate divs, one hidden and the other visible: <div id="one"> <canvas id="myChart1" width="400" height="400"></can ...

How can you show several copies of an image on an HTML page?

I am trying to show an image multiple times in a row using a combination of HTML, PHP, and CSS. Here is my code snippet: for ($i=20; $i<=320; $i=$i+300) { echo "<style> " . ".test{" . "position: absolute; left: " . $i . ...

What is the process of extracting a URL and inputting it into a form to enhance

Can anyone help with extracting a specific value (TEXT) from a URL and automatically paste it into an input form field? For example, if the URL is domain.com/page?code=123abc, I need to grab the code (in this case, 123abc) and have it automatically popula ...

Implementing an HTML5 Media Player with AngularJs via the $http Service

HTML View <audio ng-src="{{vm.videourlsce}}" autoplay preload="auto" controls="controls" autobuffer></audio> Retrieve data from a server in my controller using the $http service and update it to the player. var vm = this; vm.videourlsce = &a ...

Ways to alter the CSS class of individual labels depending on the content of textContent

In my HTML template, I'm using jinja tags to dynamically create labels from a JSON object. The loop responsible for generating this content is detailed below. <div class="card mb-0"> {% for turn in response %} <div class="card-he ...

Angular not functioning properly with alert windows

Here is a snippet of code where I am attempting to create an alert when a button is clicked: <!DOCTYPE html> <html> <head> <title></title> </head> <body ng-app> <button ng-click="alert('test')"> ...

Sending AJAX data by clicking a link in Laravel 5

I am new to working with ajax and Laravel 5 I am facing some issues with passing data when clicking on a link. Let me explain what I am trying to achieve. Here is my HTML code: //this is the div that I want to append with data for each <div id="warun ...

Moving Text Over a Static Background Image in HTML and CSS

Currently working on developing a website that involves coding in HTML and CSS. However, I've encountered an issue while programming. Whenever I attempt to adjust the positioning of my text, the background image shifts along with it, making it impossi ...

A guide on updating the appearance of a list of comma-separated tags using HTML, CSS, and jQuery

Is there a way to replicate the functionality of the tag section on this website for creating question entries? How can this be achieved? ...

What is the best method for loading multiple HTML files into a Div container?

Recently, I made the decision to improve the look of an online manual I have been working on for my company by incorporating Bootstrap. The manual is structured with a tree-view that contains titles linking to HTML files with information and CSS stylesheet ...

There seems to be a clash between Modal Semantic UI React and Bootstrap causing issues

I created a project using .net core MVC. I have integrated the semantic-ui-react modal by importing its library and linking the CSS for it to function properly. However, I encountered an issue where the bootstrap CSS was conflicting with the CDN for semant ...

Using Svelte to effectively connect to a specified object within an array

Check out this code snippet: <script> let data = [ {id: 1, first: "x"}, {id: 2, second: "y"} ]; </script> <input type="text" bind:value={data.first}/> If you modify the value in the input field and ...

Managing the height of a hero section with TailwindCSS and React.js

Embarking on my first website project using React and Tailwind has been an exciting learning experience. My vision is to showcase a Hero Section prominently at the top, with a Nav bar situated elegantly at the bottom of the screen. To bring this concept ...

Pass information from a row to an AngularJS controller upon clicking the checkbox within the row

I need help with some HTML code that utilizes AngularJS to display a table. Each row in this table contains a checkbox. Here is a snapshot of the table layout: https://i.sstatic.net/ibDor.jpg Below is the actual HTML code: <div ng-app ng-controll ...

The menu-item is unable to be centered in its location

I've exhausted all my efforts, but still can't seem to center this menu-item. Here is the code I've been working with: <div class="nav nav-tabs mb-2" id="nav-tab" role="tablist"> <a class="nav-item nav-link active" id="na ...

Guide to displaying a task within a table cell after a user submits the form

<?php $servername = "localhost"; $username = "u749668864_PandaHost"; $password = "Effy1234"; $dbname = "u749668864_PandaHost"; $q = $_REQUEST["task"]; $task = $q; echo $task; $conn->close(); ?> Exploring the world of ajax has left me scratching ...

What purpose does tagging serve in my template for polymer property binding?

I'm currently exploring the way Polymer handles the rendering of properties in a custom element's template. I've come across some interesting behavior that I haven't been able to fully grasp yet. Specifically, I noticed that certain pro ...

Use body height set to 100% to measure the scrollTop distance

I am faced with a challenge on my webpage where I need to adjust the height due to scrolling elements, while also detecting the scrollTop() distance to apply some CSS to the navigation bar. Despite setting the body's height to 100%, it appears that I ...