Ways to create unique hover effects for images in a filter gallery

I recently downloaded a filter gallery from this link and while everything is working fine, I noticed that the hover effect remains the same for all images. The code snippet responsible for this hover effect looks like this:

<div class="portfolio">
    <article class="entry web trad">
        <a data-rel="prettyPhoto" href="portfolio-barn-owl.html">
            <img class="top1" src="images/knop-1.jpg" alt="">
            <span class="magnifier"></span>
        </a>
    </article>

    <article class="entry trad">
        <a data-rel="prettyPhoto" href="#">
            <img class="top1" src="images/knop-gandalf.jpg" alt="">
            <span class="magnifier2"></span>
        </a>
    </article>

.magnifier {
    background:url(images/button-hover.jpg) no-repeat center;
    width:283px;
    height:283px;
    position:absolute;
    top:10px;
    left:10px;
    bottom:10px;
    right:10px;
    opacity:0;
    -webkit-transition:all .3s ease-in-out;
    -moz-transition:all .3s ease-in-out;
    -ms-transition:all .3s ease-in-out;
    -o-transition:all .3s ease-in-out;
    transition:all .3s ease-in-out;
}
.magnifier2 {
    background:url(images/button-hover-gandalf.jpg) no-repeat center;
width:283px;
height:283px;
    position:absolute;
    top:10px;
    left:10px;
    bottom:10px;
    right:10px;
    opacity:0;
    -webkit-transition:all .3s ease-in-out;
    -moz-transition:all .3s ease-in-out;
    -ms-transition:all .3s ease-in-out;
    -o-transition:all .3s ease-in-out;
    transition:all .3s ease-in-out;
}
.entry:hover, .entry:hover .magnifier .magnifier2 { 
    opacity:1; 
} 

The issue arises as the magnifier hover effect is applied to all images uniformly. I attempted to create a new magnifier called magnifier2 with a different image and associated CSS rules using .magnifier2, but unfortunately, it did not work as expected.

If anyone has an alternative solution to address this problem, I would greatly appreciate your input!

Thank you!

Answer №1

After reviewing the code from the provided link, if you replaced both occurrences of magnifier with magnifier2 and it still didn't work, then it's likely that you forgot to include this specific CSS rule:

.entry:hover .magnifier2 { opacity:1; }

Since the original setting for .magnifier is opacity:0, this additional rule is essential for it to become visible.

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 functionality of loading images with Jquery Ajax seems to only be working in Firefox. I have a feeling it may be due to a

I recently developed a web application that successfully loads images using a combination of jquery, ajax, and json. While it functions flawlessly in Firefox, Safari and Chrome present some stubborn challenges. The issue seems to stem from a "race conditi ...

Tips for transitioning this JavaScript code into jQuery syntax

Below is my JavaScript code: javascript: function executeCode() { var d = document; try { if (!d.body) throw (0); window.location = 'http://www.example.com/code?u=' + encodeURIComponent(d.location.href); } catch (e) { ...

Minimize the gap between col-lg elements in responsive mode within Bootstrap

My website is built using Bootstrap 4 and the following is the HTML code: <div class="container"> <div class="row text-center "> <div class="col-lg-6">A</div> <div class="col-lg-6">B</div> </div> < ...

What is the best way to create a three-column layout that completely fills the width of a page, utilizing pixel measurements on two of the columns

Click here for the jsFiddle link: Is it possible to make div2 and Button2 fill the remaining width of the window while using pixel measurements on columns 1 and 3? This formatting will be applied to a form where a textbox needs to adjust its size based o ...

Dealing with numerous identical ajax requests in jQuery

With 5 text fields where various amounts are entered, I utilize AJAX calls for calculations based on these values. The issue arises when the same AJAX call is repeated each time a user types in order to determine the total amount. The problem lies in the ...

Is it possible to execute appendChild in the context of JS-DOM-creation?

Hey there, I'm a newbie trying my hand at DOM creation. I've encountered a strange issue with appendChild - the first and second tries work fine, but I'm completely stuck on the third attempt. Here's my HTML: <html> <head> ...

Is there a way to trigger an ajax call specifically on the textarea that has been expanded through jQuery?

Whenever I expand a textarea from three textareas, all three trigger an ajax call. Is there a way to only call the ajax for the specific expanded textarea? I tried using $(this).closest('textarea').attr('id'), but it didn't work. A ...

Issue with jQuery ajax failing to access main file

When using jQuery ajax, I encounter a problem where my request from the ~/profile page gets captured at ~/profile/send_request instead of going to the ~/send_request page. Here is the code snippet: function sendRequest() { var id = document.ge ...

What is the best way to initiate actions once the form has been successfully processed?

Could someone assist me with creating a form that hides after submission and displays a thank you message instead? I've tried the code below, but it seems that the action isn't being executed once the form is submitted. It's as if the ' ...

Unable to store cookie using jQuery on Internet Explorer 9

Having trouble setting a cookie on IE9 and can't figure out why. My objective is to create a cookie that expires after a year, using the code below: $.cookie( name, value, { expires:days } ) where days equals 365. However, the cookie disappears as s ...

Ways to transfer data from TypeScript to CSS within Angular 6

Trying to work with ngClass or ngStyle, but I'm struggling with passing the value. Here's my current code: strip.component.ts import { ... } from '@angular/core'; @Component({ selector: 'app-strip', templateUrl: &apo ...

Display the number of likes without having to refresh the page

On my website, there is a like/unlike post feature. When I click the like button, I want the value of check2 to appear next to the like button without needing to refresh the page. Currently, after clicking like, the data is inserted but only appears after ...

The feature for automatically hiding other dropdowns when one is open is not functioning properly

Trying to finalize a mega menu that almost works. I need help with closing all other open mega menus when a user clicks on one. Check out the JavaScript code snippet I've written below. The mega menu currently toggles correctly, but it doesn't h ...

jQuery function failing to produce the intended results

I am trying to apply the active class to the last img element using HTML and jQuery Below is my code in HTML and jQuery: function initialSteps() { $(".row").find("column:last").find("img:first").className += " active"; // this does not work either ...

By default, the select option in AngularJS will have a value of either an object or null

This block of code is located in the js file: $scope.ListOption = []; $scope.ListOption.push({ Value: "0", Name: Car }); $scope.ListOption.push({ Value: "1", Name: House }); Below is the corresponding HTML code: <select class="form-control" id="Categ ...

When retrieving data from a PHP $_SESSION using an Ajax $_POST call, outdated information is being returned

I am encountering an issue that I cannot seem to figure out. Currently, my application consists of three pages: Home.php Nearmiss.php Reports.php Each of these pages includes code at the top with a specific "thispage" variable unique to that page. < ...

I'm interested in clicking on an image within a div to trigger a page refresh and then automatically hide the div once the page has refreshed

UPDATE 2 SITUATION To prevent access to quiz content until the page is refreshed, I am employing a semi-transparent image with a top-margin off-set. The following code functions flawlessly on one specific page and only once: JavaScript window.addEventL ...

Tips for personalizing Bootstrap columns using identical class names?

Is there a way to customize the background color of each individual .col-5 within the same row while using Bootstrap and a custom CSS file? Changing the styles for one column seems to affect all columns with the same class name. Edit: I'm looking f ...

When using jQuery's .appendTo() method in Internet Explorer, the images on the page may fail to render properly unless the browser

When using the jQuery functions .render() and .appendTo to display images and text on a webpage within a placeholder/template, I encountered an issue specifically with Internet Explorer. In IE, the images were not rendering automatically, instead displayin ...

What is the best way to show an array within a string using javascript?

Take a look at this code snippet : const names = ["Alex", "John", "Kit", "Lenny"]; for(let i = 0; i < 4; i++) { $("body").append("<p>" + names[i] + "</p>'); }; Can you figure out how to dynamically add each item in the 'names&a ...