Hovering over elements without triggering their appearance

My CSS includes hover conditions for specific divs, such as a parent relationship transition (#playing-field:hover #cont2) and a self transition (#piccont2:hover), but they don't seem to be working properly. The only hover effect that works is the a:hover.

I'm wondering if there's something in the overall style that might be causing these hover transitions not to work as expected. Am I misunderstanding how to create a hoverable div?

http://jsfiddle.net/t3s8hxcL/

a:hover {
    color:green;
}

html, body {
    font-size: 18px;
    color: white;
    font-family:'Oswald', sans-serif;
    margin: 0;
    padding: 0;
    overflow:hidden;
    height:100%;
    width:100%;
}

#header {
    height: 10vh;
    /*100 */
    background: #ed3144;
    /* ruby */
    text-align: right;
    position: relative;
    box-shadow: 0px 5px 3px black;
}

#footer {
    height: 13.5vh;
    /*100 */
    background: #181616;
    /* almost black */
    text-align: right;
    position: relative;
    top: -6vh;
    z-index: -1;
}

#above-footer {
    height: 3vh;
    background: #FFD700;
    position: relative;
    top: -13vh;
    z-index: 0;
}

#header-content {
    position:absolute;
    bottom:5px;
    right: 10px;
}

#dropbin {
    position: relative;
    text-align:center;
}

#dropbinbar {
    height:3.5vh;    
    /*35*/
    background: #181616;
    /* almost black */
    z-index: -3;
}

#bin {
    height: 6vh;
    /*60*/
    width: 13%;
    background: #635856;
    /*greyish*/
    z-index: -1;
    box-shadow: -5px 5px 3px #181616;
    text-align: center;
    float:left;
}

#bin-content {
    position:absolute;
    text-align: center;
    /*text-transform: uppercase;*/
    font-size: 30px;
    font-size: 1.5vw;
    font-weight: normal;
    bottom: .5vw;
    width: 100%;
}

#playing-field {
    height:73vh;
    /*865*/
    clear:both;
    overflow: hidden;
    position:relative;
    top: -6vh;
    z-index: -10;
}

#playing-field:hover #cont2 {
    height: 80%;
    background: #ed3144;
}

#piccont1 {   
    width: 200px;
    height: 200px;
    background-color: #ed3144;
    /* ruby */
    margin:0 auto;
    position: absolute;
    top: -webkit-calc(50% - 100px);
    top: -moz-calc(50% - 100px);
    top: -calc(50% - 100px);
    left: -webkit-calc(25% - 100px);
    left: -moz-calc(25% - 100px);
    left: -calc(25% - 100px);
    z-index: 0;
}

#piccont2 {
    width: 200px;
    height: 200px;
    background-color: black;
    margin: 0 auto;
    position: absolute;
    top: -webkit-calc(50% - 100px);
    top: -moz-calc(50% - 100px);
    top: -calc(50% - 100px);
    left: -webkit-calc(75% - 100px);
    left: -moz-calc(75% - 100px);
    left: -calc(75% - 100px);
    z-index: 0;
}

#cont1 {
    width: 50%;
    height: 100%;
    float: left;
    background: black;
    z-index: -4;
}

#cont2 {  
    width: 50%;
    height: 100%;
    float: right;
    background: #ed3144;
    z-index: -3;
}

#piccont2:hover :   
    -webkit-transform: translate(3em, 0);
    -moz-transform: translate(3em, 0);
    -o-transform: translate(3em, 0);
    -ms-transform: translate(3em, 0);
    left: -webkit-calc(50% - 100px);
    left: -moz-calc(50% - 100px);
    left: -calc(50% - 100px);
    background-color: #ed3144;
}

Answer №1

Your approach of utilizing negative Z-index values is causing most elements to be placed behind the body in the Z-stack. This results in the hover behaviors on individual elements not being triggered correctly. When inspecting the #contX elements, Chrome will highlight the <body> element because it's the first one encountered from top to bottom.

Avoid using Z-values below 0 unless you have a specific and well-justified reason for doing so. Understanding the intricacies and consequences of manipulating Z-index is crucial in CSS.

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

The content selected in a bootstrap multiselect dropdown may break across multiple lines

I am currently using a bootstrap multiselect dropdown to display all the selected values in the dropdown. However, I now have a large number of values and would like to break them into multiple lines. This is how it currently looks like displayed in the im ...

What is the best way to format log lines in a GWT custom logging section?

In GWT, a personalized logging area can be created by implementing a HasWidgetsLogHandler. In my situation, I am using a VerticalPanel. However, the logging output is too wide and distorts the rest of the page. How can I wrap the lines? Each log entry add ...

The arrangement vanishes when using identical html/css coding

When using the same HTML/CSS coding, the layout disappears and appears misaligned on one page but works perfectly on another. The issue seems to be that the first section of the main area is getting a width of 938px instead of 5px. I've tried adding w ...

Distinguish using section class in Selenium

Currently grappling with a Python selenium issue, I need to extract and print an email address in my code: [email protected] Just looking for a hint... HTML: <section tabindex="-1" class="pv-profile-section pv-contact-info artdeco- ...

Switch out div elements for td elements in HTML code

I have written a code snippet that successfully toggles between showing and hiding content. Here is the code: Simple collapsible Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliq ...

Unresponsive Hover Effect on iPad

I've implemented a hover effect on the menu for my one-page website. When a user hovers over a navigation link on desktop, the color changes to #ed1c28. .nf-navbar .navbar-collapse a:hover { color: #ed1c28; } Additionally, when a user clicks on a ...

Discovering tags that are isolated and encasing them with specific tags

After researching Beautifulsoup, I am looking to identify <a> elements that are not nested within <p> tags and then wrap them with <p>, but I am unsure of the process <p><a href="example1.com">example1.com</a></p> ...

wrap text image not compatible with responsive layout

Plunker Link: https://plnkr.co/edit/kC9SPK2e7iy5OYhKpwOO?p=preview <html> <head> <link data-require="bootstrap@*" data-semver="4.1.3" rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" /> ...

Invoke a specific URL during an HTML5 upload

So I've got this code that allows for file upload via drag and drop using HTML5 in the browser. $(function(){ var dropbox = $('#dropbox'), message = $('.message', dropbox); dropbox.filedrop({ // Customizing upload settin ...

Tips for seamlessly incorporating advertisements into a mixed application

I am having trouble adding banner ads to my hybrid application developed with Telerik. Despite my extensive research, I have been unable to find a suitable solution. Is there any html5 or javascript banner advertising service/API that is compatible with ...

What is the best way to include an active CSS class in a menu item?

Link to example Can you figure out why the Home button is not turning red in this code snippet? .navbar a:hover, .navbar a:focus, .navbar a:active { color: red !important; } <nav class="navbar navbar-expand-lg"> <div class="collapse navbar ...

Enhancing react-input-range with unique Custom Arrow heads

I'm currently working with react-input-range to create a price range slider. While I've managed to customize the CSS of the range slider, I now need to figure out how to add arrow heads inside the circles as shown below: https://i.sstatic.net/pm ...

Steps for transforming numerous HTML tables into a pandas dataframe with the help of a personalized method

I've been facing a challenge in converting multiple HTML tables into a pandas dataframe. I created a function to achieve this, but it's returning an empty list [] instead of the desired pandas dataframe. Here is my current approach: Gathering al ...

Executing a C# function from an HTML hyperlink

I am in the process of developing a website using ASP.NET C#. The site will feature a GridView with data that can be exported, such as to Excel or other formats. To handle the export functionality, I plan to utilize code from this resource. When a user c ...

My code seems to be experiencing issues with the carousel functionality despite incorporating Bootstrap

<div id="carouselExampleControls" class="carousel slide" data-ride="carousel"> <div class="carousel-inner"> <% campground.images.forEach((img,i)=> { %> ...

What could be the reason for Firefox failing to display the border of a table when the tbody is

If Firefox isn't displaying table cell borders correctly in the presence of an empty tbody, a simple solution is to use the pseudo selector tbody:empty {display:none;} to hide the empty tbody element. This will ensure that everything is rendered as ex ...

The Angular8 form encounters an error when trying to access the 'valid' property of an undefined value

I am implementing a register form to add an employee and including validation for accuracy. However, I encountered an error message that reads "cannot read property of 'valid' of undefined." Here is the code snippet: HTML <div class="conta ...

When using Flask, adding type=module to the src tag in HTML causes JavaScript to cease functioning

The task I had anticipated to be the simplest component of my project has transformed into a monumental challenge. My initial objective was to extract data from a JSON file for display on my website. Prior to implementing the JSON file, I manually input so ...

The source of the image gets disrupted when it is not on the homepage

My images are stored in the directory images/icons/artist_default.png On the homepage, the image is displayed with this path: http://localhost:7777/images/icons/artist_default.png However, on a user's page like http://localhost:7777/user/giorgio-m ...

Avoid filling the container with an excessive amount of grids while maintaining the correct aspect ratio

I encountered a situation where I needed to dynamically create a grid with square grids of dimensions MxN. Below is the code snippet for achieving this: rerender = (event) => { const height = document.getElementById("y-input").value; const width ...