Attempting to achieve the simultaneous display of an image overlay and image zoom when hovering over the mouse

I'm struggling to display an image overlay and image zoom simultaneously when hovering the mouse. After adding the image zoom effect, the overlay disappears. It seems like one transition is overriding the other. Whenever the zoom works, the overlay doesn't show up and vice versa. I've been researching this issue for hours without success. Any assistance would be highly appreciated as I cannot seem to find a solution.

HTML Code:

<div class="image_wrap">
    <div class="caption">
        <i class="fa fa-search-plus" aria-hidden="true"></i>
        <p class="heading">
            Resort Website
        </p>
    </div>
    <img src="css/images/resort.jpg" alt="resort" class="portfolio-pic">
</div>

CSS Code:

 .image_wrap{
   position:relative;
 }

.image_wrap .caption{
  position:absolute;
  width:100%;
  height:100%;
  opacity: 0;
  text-align:center   
  display:inline-block;
  background: linear-gradient(rgba(51, 153, 170, 0.9), rgba(51, 153, 170, 0.8));
  -webkit-transition:all .4s ease-in-out;
  transition:all .4s ease-in-out
}

.image_wrap .caption:hover{
  opacity: 1;
}

.image_wrap .caption img {
  position:relative;
  -webkit-transition:all .4s linear;
  transition:all .4s linear;
}

.image_wrap .caption:hover img {
  -ms-transform:scale(1.2);
  -webkit-transform:scale(1.2);
  transform:scale(1.2);
}

Answer №1

I have identified two issues in your code that need to be addressed. Please make the following changes:

.image_wrap .caption:hover img {
-ms-transform:scale(1.2);
-webkit-transform:scale(1.2);
transform:scale(1.2);
}

Replace it with:

.image_wrap:hover img {
   -ms-transform: scale(1.2);
   -webkit-transform: scale(1.2);
   transform: scale(1.2);
   z-index:8;
 }

The reason for this change is that the image is not within the .caption class, and the z-index was not previously declared for the caption placed over the image.

Make sure to also add the z-index to the caption:

.image_wrap:hover .caption {
   opacity: 1;
   z-index:9999;
 }

For testing purposes, you can view the updated code on jsfiddle by following this link.

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

Responsive design with Semantic UI

Can you please provide an example of how to design for different screen sizes using Semantic UI instead of Bootstrap? I'm looking for something similar to Bootstrap's sm and lg classes. For instance, would it look like this: <div class="col s ...

Searching using wildcards in a single text field in MySQL using PHP on a web page created with

Recently, I acquired some PHP scripts from a coworker that includes a search functionality for the "Notes" text field in a database named "Sheep". The search is conducted through a text box: https://i.sstatic.net/NbwMF.png Here is the code for the search ...

Is AsciiEffect.js compatible with CSS3DRenderer.js in combination with three.js/WebGL?

Having trouble using the AsciiEffect.js and CSS3DRenderer.js together, wondering if it's possible without tweaking... here's the concept var W = window.innerWidth, H = window.innerHeight; renderer = new THREE.CSS3DRenderer(); effect = new THREE. ...

Issue with Rendering Rapheal Pie Chart in Internet Explorer 9

I encountered an issue in IE9 where I received the error message "SVG4601: SVG Path data has incorrect format and could not be completely parsed" while trying to draw a pie chart on an HTML5 page using Raphael JS and SVG. The problem arose when the "d" att ...

Modifying Checkbox BorderWidth in Material UI v5

Seeking assistance with adjusting the checkbox border width in Material UI v5. I currently have a custom checkbox and would like to remove the border width. Despite trying numerous solutions, I have been unsuccessful so far. checkbox <Checkbox de ...

Hiding horizontal lines in a table without affecting vertical lines (Material-ui) - a step-by-step guide

Is there a way to hide the horizontal lines and timeslots in the table below without affecting the vertical lines? I attempted to use the visibility property on the td elements, but it hides both sets of lines. Any suggestions on how to resolve this is ...

When applying the `display:block` and `width:100%` attributes to an HTML table cell, it may

My issue lies in the usage of DISPLAY:BLOCK for the td cells with a class of column. Despite applying it appropriately, the logo and CALL US td cells do not stack vertically when resized to mobile size. While they are supposed to take up 100% width, they ...

Tips for retrieving the selected option from a dropdown menu

I have a dropdown menu with checkboxes that can be selected using SumoSelect. Here is the markup for the dropdown menu: <select multiple="multiple" name="somename" id="uq" class="select"> <option value="volvo">Volvo</option> <o ...

The background colors are not extending to the full width of the screen

I am facing an issue in my CSS code while trying to create a footer. The background color is not filling the width of the screen, and I had encountered the same problem earlier. Here is how it looks: (https://i.sstatic.net/5VxYU.png) HTML Code: *{ ma ...

Adjust the default margins and padding of email header images specifically for Outlook emails

I am currently working on coding an email, and I have encountered an issue with the alignment of the hero image, specifically in Outlook. https://i.sstatic.net/ap7SG.png Despite trying various solutions from previous answers to this problem (such as sett ...

React's input onChange event does not trigger for the second time. It only works the first time

Recently, I developed a React JS application to import images from external sources and process them. To handle the user's onChange event, I utilized the onChange attribute to execute my handleChange function. However, I encountered an issue where it ...

Tips for adding a personalized close button to a Bootstrap modal

I need help with a Bootstrap modal in my project that has a close button positioned at the top right corner. I've used CSS to position the button, but it's not staying in one place consistently despite applying absolute positioning. I've tri ...

Ways to create adaptive images using Bootstrap 5

On my website, there are some cards that look great on large and medium screens. However, on small screens, the images appear stretched vertically! I am using Bootstrap 5 and here is the code snippet: <div class="col-12 mb- ...

Applying Media Queries Based on Element Height

Situation: In my scenario, there is an image with two buttons below it, all of which share the same width. Issue: When the viewport is too wide horizontally, the buttons are not visible without scrolling down. This poses a challenge for tablets and small ...

Exporting Python Pandas Data Frame to an HTML file

I'm attempting to save a Python Pandas Data Frame as an HTML page. I also want to ensure that the table can be filtered by the value of any column when saved as an HTML table. Do you have any suggestions on how to accomplish this? Ultimately, I want t ...

javascript include new attribute adjustment

I am working with this JavaScript code snippet: <script> $('.tile').on('click', function () { $(".tile").addClass("flipOutX"); setTimeout(function(){ $(".tile-group.main").css({ marginLeft:"-40px", widt ...

Count in JavaScript that picks up where it left off

I'm working on setting up a countdown timer that runs for 24 hours, showing the days, hours, minutes, and seconds. The challenge I'm facing is how to save the progress of the countdown. Essentially, I want it to resume from where it left off for ...

How to circumvent an email forwarder that removes attributes from an image tag and still track email opens?

While it may seem like an impossible task, I decided to give it a try. If the service I am utilizing removes the attributes of an image tag =>, is there a workaround available? I attempted inserting random unicode characters to disrupt the parser, but ...

Align several labels and text areas in the center

I am facing an issue with aligning multiple labels and textareas together. Currently, they line up like this: __________________ | | | | Label:|__________________| However, I want them to appear as fol ...

Revamp Child Relationship in Ruby on Rails Form

One of the challenges I'm facing is with editing and updating priorities for parent accounts in my application. The "Accounts" model acts as the parent, while the "Priorities" model serves as the child. Creating new priorities for these accounts is s ...