Using HTML z-index to apply filter effects

I am currently utilizing images as radio buttons, but I am encountering an issue with CSS filter effects impacting the z-index properties.

Here is a sample fiddle that I have created to demonstrate the problem:

https://jsfiddle.net/iambong/2kcvv3bL/1/

CSS:

.colour-black{background-image:url(https://s28.postimg.org/p585381cd/Colour_Black.png);}
.colour-blue{background-image:url(https://s24.postimg.org/clxbf89g5/Colour_Blue_suede.png);}
.colour-chestnut-brown{background-image:url(https://s23.postimg.org/swdj7nh6z/Colour_Chestnut_Brown.png);}

.colour-selector input{
position:relative;
z-index:2 !important;
overflow: hidden;
background-repeat:no-repeat;
border: none;
margin:0;padding:0;
-webkit-appearance:none;
   -moz-appearance:none;
        appearance:none;
 }

.colour-selector input:active +.colour-cc{opacity: 0.9; position:relative;    z-index:2;}
.colour-selector input:checked +.colour-cc{
position:relative; 
z-index:2;
-webkit-filter: none;
   -moz-filter: none;
        filter: none;
}

.colour-cc{
positon:relative;
  z-index:3 !important;
background-size:contain;
background-repeat:no-repeat;
display:inline-block;
overflow: hidden;
padding: 8px;
margin-bottom: 8px;
align: left;
width:100px;height:70px;
-webkit-transition: all 100ms ease-in;
   -moz-transition: all 100ms ease-in;
        transition: all 100ms ease-in;
-webkit-filter: brightness(1.8) grayscale(1) opacity(.7);
   -moz-filter: brightness(1.8) grayscale(1) opacity(.7);
        filter: brightness(1.8) grayscale(1) opacity(.7);
}

.colour-cc:hover{
 positon:relative;
 z-index:10 !important;
 overflow: hidden;
 display:inline-block;
-webkit-filter: brightness(1.2) grayscale(.5) opacity(0.9);
   -moz-filter: brightness(1.2) grayscale(.5) opacity(0.9);
        filter: brightness(1.2) grayscale(.5) opacity(0.9);

-webkit-transform:scale(2.5); /* Safari and Chrome */
-moz-transform:scale(2.5); /* Firefox */
-ms-transform:scale(2.5); /* IE 9 */
-o-transform:scale(2.5); /* Opera */
 transform:scale(2.5);
}

HTML:

<p>Colour Selection</p>                  

 <div class="colour-selector"; style="position:relative; left:100px; top:50px; z-index:1;">

     <input id="colour-black" type="radio" name="properties[colour]" value="colour-black" style="position:relative; z-index:3;"/>
     <label class="colour-cc colour-black" for="colour-black"></label>
       <input id="colour-blue" type="radio" name="properties[colour]" value="colour-blue" style="position:relative; z-index:3;"/>
     <label class="colour-cc colour-blue" for="colour-blue"></label>
     <input id="colour-chestnut-brown" type="radio" name="properties[colour]" value="colour-chestnut-brown" style="position:relative; z-index:3;"/>
     <label class="colour-cc colour-chestnut-brown" for="colour-chestnut-brown"></label>

</div>

Desired Outcome: I would like the magnified image on mouse-over (hover) to display without showing parts of neighboring images.

Current Issue: Currently, when hovering over the middle picture, the magnified image using transform scale in the CSS shows parts of the neighboring images.

Any assistance is greatly appreciated! Thank you!

Answer №1

Here is an example of how you can structure your code:

#nav{z-index:2}
#nav li{display:inline-block;
    text-align:center;
    padding:10px;
    color:#fff;
   
    cursor:pointer;
height:50px;
  width:100px;
list-style-type:none;}

#nav ul li:nth-child(1){background:#b4b4b4;}
#nav ul li:nth-child(2){background:#cecece;}
#nav ul li:nth-child(3){background:#b4b4b4;}


#nav ul:hover li {
          transform: translateX(-24%);
    z-index:4;
}
#nav ul:hover li:hover {
 
          transform: scale(1.5);
          transition-duration: 0.18182s;
}
#nav li:hover ~ li {
          transform: translateX(24%);
    
}
<div id="nav">
    <ul>
    <li><p></p></li>
    <li><p></p></li>
    
    
    <li><p></p></li></ul>
    
    
          
        
    </div>

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

two occurrences of the identical controller in AngularJS

Encountering a dilemma (admittedly, not the best approach). There is a single view featuring a split screen; an input field occupies the left side while its corresponding value appears on the right. Both sides are managed by the same controller, using the ...

Looking for a solution to save data without internet access through a web application

My goal is to develop a web application using HTML5, CSS3, and potentially JQuery Mobile. The purpose of this app will be to gather customer data through a form, with the added requirement of being able to operate offline. In the past, I have built offlin ...

What is the method for connecting the text to its parent element in SVG?

I have put together a demo at https://codepen.io/anon/pen/rzLEQX, but I am trying to figure out how to ensure that the text is contained within the 'g' container with the id of "g12". Do I need to use variables x and y for this? <g id="g12" ...

Creating a table that adjusts its columns to match the same width percentages for a responsive design

Three tables were created with identical column names. The HTML markup for each table is consistent. When viewed on a laptop browser, the tables display correctly as depicted in this screenshot: https://i.sstatic.net/5BAdg.png However, when viewed on a s ...

Is there a way to reduce the height of the year dropdown list in the datepicker? It currently extends too far and takes up a lot of space in the viewport

I've been struggling with the height of a dropdown list for years. Despite my attempts to solve it with CSS, it seems to be more complicated than that. Online searches have not yielded the solution I need, and the documentation isn't providing th ...

Error encountered: Java NullPointerException in Applet

When attempting to embed an applet into an HTML file for a university class demonstration, I consistently encounter a NullPointerException dialog upon execution. What could be causing this issue? <html> <head> <title> My Pacman Gam ...

Are there any tools available that can convert inline styles into CSS classes?

Can anyone recommend a package that will transform this text: <p style="width: 500px; height: 500px"> Hello World </p> into this format: <p class="foo"> Hello World </p> .foo { width: 500px; height: 500px; } ...

What steps can I take to ensure that my popup images continue to appear?

Currently, I am working on creating a webpage that features thumbnails sourced from a local geoserver. The goal is to have these thumbnails expand into dialog windows that can be moved around. While I have successfully implemented the functionality to expa ...

Tips for achieving a Google Map that smoothly slides behind a sticky header as you scroll

I recently added a sticky header using CSS to my long HTML page. At the bottom of the page, there is a <div> element with a Google Map embedded in it. As I scroll down the page, the content scrolls behind the sticky header as expected, but the Googl ...

Top Margin: Supported by Chrome and Safari

After troubleshooting why the margin-top is not working on Safari, but works fine on Chrome, I discovered a discrepancy. Chrome Upon hovering over an item in the image, the cursor changes as expected. This feature operates smoothly in Chrome. https://i. ...

Extracting text or value from a <span> element using its unique ID and storing it in a variable from a different website using cURL in

I am trying to retrieve the value or text within a span with a specific id from an external website using cURL. Once I have obtained this value, I need to store it in a variable. Here is an example of the span I am looking for: <span id="company" clas ...

Embracing New and Returning Users with Jquery Cookies: A Guide on Making Every User Feel Welcome

I'm currently working on setting up a Welcome page for both new and returning users using cookies with jQuery. However, I've encountered an issue where upon submitting the form with new user data, the message displayed is not "Welcome New User," ...

Footer Design Problems

There seems to be some strange behavior with the footer on my website. In the demo, you'll notice that the HR tag in the location section is being pushed to the bottom of the page, altering the layout. Additionally, I'm attempting to make the Fac ...

Tips for creating smooth transitions between images in a slideshow

I am looking to create a slideshow that displays images with crossfading while simultaneously highlighting radio buttons below it. I also want the slideshow to pause when the mouse hovers over an image. However, I am experiencing issues with the background ...

Two servers, each with its own designated form, and a singular database

Hello, I'm managing two servers. One of them has a form and MySQL database where I input data. The other server only includes a form where I want the data filled in to be sent securely to the first server's database. What is the best method for i ...

What is the proper way to pass options using jquery.timeline.js?

My implementation of jquery.timeline.js involves initializing the timeline using the script below: <script> $(function () { $("#myTimeline").Timeline({ startDatetime: "2019-02-25 00:00", rows : 5 }) }) </script&g ...

The colors of my SVG button remain constant and do not dynamically change when I hover over it

I am facing an issue with a button that contains an SVG element. In my CSS, I have defined styles to change the color of the icon and the SVG when hovered over. However, I noticed that I have to directly hover over the SVG itself for the color to fill. As ...

What is the best method for determining the REM value of a particular type

Can you help me understand how to convert PX into REM for my typography? I came across Jonathan Snook's article on utilizing REM units, but I'm a bit confused about his suggestion of using font-size: 62.5% as a base for conversion (setting the de ...

transition effect of appearing and disappearing div

Having trouble creating a fade out followed by a fade in effect on a div element. The fade out happens too quickly and the fade in interrupts it abruptly. Here is the JavaScript code: $('#fillBg').stop(true,false).fadeTo(3000, 0); $("#fillBg"). ...

Personalized Design Incorporating Sections and Sidebars

I need the aside to be positioned on the right side and the section on the left side, both centered in the space. Feel free to check out this link <!DOCTYPE html> <html> <head> <style> #main { width: 800px; margin: 0 auto; } ...