Enhance your images with a hover zoom effect while viewing an overlay on top

Is there a way to make an image still zoom in on hover even when it has an overlay using CSS?

I am currently working with Bootstrap 5.2

Thank you in advance.

.trip-card {
  position: relative;
}

.trip-card img {
  border-radius: 30px;
}

.overlay {
  position: absolute;
  border-top-left-radius: 30px;
  border-top-right-radius: 30px;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  background: rgba(66, 66, 66, 0.525);
}


/*zoom does not work when there is overlay*/

.zoom-effect-1 {
  overflow: hidden;
}

.zoom-effect-1 img {
  border-radius: 30px;
  transform: scale(1);
  -webkit-transform: scale(1);
}

.zoom-effect-1:hover img {
  transform: scale(1.1);
  -webkit-transform: scale(1.1);
}

.effect-image-1 {
  border-radius: 30px;
  position: relative;
  display: block;
}

.zoom-effect-1 img {
  transition: all .4s linear;
  -webkit-transition: all .4s linear;
  -moz-transition: all .4s linear;
  -o-transition: all .4s linear;
}
<body>
  <div class="trip-card p-4 col-12 col-md-6 col-lg-4 col-xl-3 ">
    <div class="effect-image-1 zoom-effect-1">
      <img src="https://picsum.photos/200" class="w-100" />
    </div>
    <div class="overlay text-white d-flex justify-content-center align-items-center m-4">
      <div>
        <h3 class="text-center">Trip Name</h3>
        <p>2 Oct 2022 - 22 Oct 2022</p>
      </div>
    </div>
  </div>
</body>

Answer №1

Your current HTML markup needs to be updated as it is causing the images to overlap. Please refer to the corrected code below. Your CSS is good, just make sure to adjust the HTML markup accordingly.

.trip-card {
  position: relative;
}

.trip-card img {
  border-radius: 30px;
}

.overlay {
  position: absolute;
  border-top-left-radius: 30px;
  border-top-right-radius: 30px;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  background: rgba(66, 66, 66, 0.525);
}


/*zoom does not work when there is overlay*/

.zoom-effect-1 {
  overflow: hidden;
}

.zoom-effect-1 img {
  border-radius: 30px;
  transform: scale(1);
  -webkit-transform: scale(1);
}

.zoom-effect-1:hover img {
  transform: scale(1.1);
  -webkit-transform: scale(1.1);
}

.effect-image-1 {
  border-radius: 30px;
  position: relative;
  display: block;
}

.zoom-effect-1 img {
  transition: all .4s linear;
  -webkit-transition: all .4s linear;
  -moz-transition: all .4s linear;
  -o-transition: all .4s linear;
}
<body>
  <div class="trip-card p-4 col-12 col-md-6 col-lg-4 col-xl-3 ">
    <div class="effect-image-1 zoom-effect-1">
      <img src="https://picsum.photos/200" class="w-100" />
       <div class="overlay text-white d-flex justify-content-center align-items-center m-4">
      <div>
        <h3 class="text-center">Trip Name</h3>
        <p>2 Oct 2022 - 22 Oct 2022</p>
      </div>
    </div>
    </div>
   
  </div>
</body>

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 HTML and CSS code I wrote functions perfectly on Codepen, but for some reason, it appears different when I view it in my Chrome environment

My codepen displays perfectly, but when I run the same code on my local environment it looks off. I can't seem to figure out what is causing the difference, especially since I copied and pasted the exact code. Both the codepen and my environment are u ...

Activate outline styling for Bootstrap radio buttons when clicked

I was in the midst of developing my bootstrap application. Every time I click on a radio button, there is a noticeable blue outline as shown here: https://i.sstatic.net/Uzm7b.png I attempted to address this issue using the following CSS code: .form-chec ...

I have a dynamic form code that allows users to insert data by adding multiple inputs in a row. However, I would like to modify it so that the inputs are added in a column instead

I found this code online that allows users to add extra inputs, but it currently only creates new rows in the database. I would like these inputs to be inserted into different columns within the same row. How can I modify it to achieve this? I have alread ...

Issue occurred while attempting to resolve tab panel identification for incorporating tab panes within Razor Pages code

So I've run into a bit of a snag here. I'm fairly new to working with Bootstrap and Razor Pages, and I can't seem to figure out why I'm encountering this error. My current project involves implementing tabs and their corresponding tab ...

Should PHP be avoided in CSS files?

I've recently developed a CSS page named style.php and at the beginning, I included this line: <?php header("Content-type: text/css"); ?> What are your thoughts on this approach? Is it considered a bad idea? The reason behind doing this is tha ...

Adjust size of item within grid component in VueJS

I have a grid container with cells and a draggable item in a Vue project. I am trying to figure out how to resize the box inside the grid component (refer to images). https://i.stack.imgur.com/q4MKZ.png This is my current grid setup, and I would like the ...

Tips for incorporating Bootstrap classes into a React project, setting the className attribute to an empty string

After setting up Bootstrap and Create-React-App using npm on my local machine, I proceeded to create a new React app. The first component I worked on was counter.jsx: import React, { Component } from 'react'; class Counter extends Component { ...

Paths to External Stylesheets

Imagine having a stylesheet body { background-image: url('/images/background.jpg'); } situated in the header section of a nearby document <html> <head> <link rel="StyleSheet" href="http://externalserver/stylesheet.cs ...

I'm looking to add a price ticker to my html webpage. Does anyone know how to do this?

PHP Code <?php $url = "https://www.bitstamp.net/api/ticker/"; $fgc = file_get_contents($url); $json = json_decode($fgc, true); $price = $json["last"]; $high = $json["high"]; $low = $json["low"]; $date = date("m-d-Y - h:i:sa"); $open = $json["open"]; ...

Revealing information about a photo when hovering over it

I am currently working on a project where I need to display images from a database in two columns. My goal is to have additional details about each image, such as the country and year it was taken, appear when I hover over them. A good example of what I&ap ...

Is there a way to adjust the width of the info panel in an SVG to automatically match the width of the SVG itself?

I am looking to place the information panel at the bottom of my SVG map and have it adjust its width according to the width specified in the viewBox. This way, even if I resize the map, the info panel will automatically adjust to fill completely based on t ...

Bespoke animated angular material tabs

Having an issue with Angular Material tabs. I have managed to remove the "slide" effect, but I can't figure out how to modify or remove the black effect behind my tab. Can anyone offer some assistance? black effect 1 black effect 2 Here is a snippe ...

Is it possible to manually trigger a version change transaction in IndexedDB?

I have been working on a Chrome extension that uses the IndexedDB to store data client-side in an IDBObjectStore within an IDBDatabase. The data structure requires users to be able to modify the object store freely, such as adding new objects or modifying ...

Is it possible to align images vertically with text in a multi-column Bootstrap 4 container?

Inquiring on how to achieve vertical center alignment of text and images for a website section similar to the one shown in this image: https://i.sstatic.net/s8gNh.jpg. The intention is to align the logos and the corresponding text of company names situated ...

Commencing CSS Animation Post Full Page Loading

I am looking for a solution using WordPress. In my specific case, I want the CSS Animations to take effect only after the page has completely loaded. For example: click here This is my HTML: <div class="svg-one"> <svg xmlns="ht ...

Applying background color within an *ngFor loop

My question may not be perfectly described by the title, but here it is. In my Angular Material2 project, I have an md-toolbar where I am dynamically looping through values: <md-toolbar (click)="selectedToolbarValue(key.Name)" *ngFor="let key of array ...

Error: Attempting to access property 'question' of an undefined value

Trying to render information from a local .json file using Javascript functions, I encountered an error in the console for const answer despite being defined. I temporarily commented it out to test the function, only to receive the same TypeError for quest ...

Incorporating RFID reader functionality into a website

I am currently facing an issue with integrating an RFID card reader into a web page. After some research, it seems that the solution involves creating an ActiveX component and using JavaScript. My question is, how can we go about building an ActiveX compo ...

Alter the typography of the text that has been enhanced by Google

I am attempting to modify the default font of certain text that is processed through google-code-prettify within an angular directive. The structure of the template served by my directive appears as follows: <pre class= "prettyprint" style= "border:1p ...

A horizontal line that seamlessly lines up with the text and icon on the Bootstrap navbar

How do I create a horizontal line centered with text and the navbar? I'm currently working on my portfolio and I want to have an icon navbar aligned to the left, and on the right side of it, I would like to have the text < / Front-end Web Develope ...