When hovering over the image, it enlarges and gradually becomes transparent, unveiling the hidden text beneath

I've been struggling to achieve the desired effect for quite some time now, putting in hours of effort without success.

Essentially, I am aiming to create a div that showcases an image. When the mouse hovers over the image, it should zoom in and fade out to reveal a blue background with a text description underneath.

I've managed to implement the zooming and fading effects, positioned the text within the div as intended, but I just can't seem to get it to appear below the image initially.

Despite trying different z-index values and opacities, the text always ends up on top of the image.

If anyone could provide guidance on resolving this issue, I would greatly appreciate it.

Below is my HTML and CSS code:

<div class="randomItem">
<div class="hidden_text">
Vintage Projects
<br>
Click to find out more
</div>
<a href="vintage.html">
<img src="img/vintage/rizla3.jpg" alt="Vintage Projects" class="randomImage">
</a>
</div>
.hidden_text        {color: white;
                    font-size: 20px;
                    position:absolute;
                    top: 50%;
                    left: 50%;
                    -webkit-transform: translate(-50%, -50%);
                    -ms-transform: translate(-50%, -50%);
                    transform: translate(-50%, -50%);
                    text-align: center;
                    cursor: pointer;}

.randomItem         {border:3px solid #ddd;
                    position:relative;
                    display:inline-block;
                    margin:0.79%;
                    overflow:hidden;
                    width:31%;
                    -webkit-transition:all .3s;
                    -o-transition:all .3s;
                    transition:all .3s;
                    background:#009fdf;}
                    
.randomImage        {display:block;
                    height:auto;
                    max-width:100%;
                    -webkit-transition:all .5s;
                    -o-transition:all .5s;
                    transition:all .5s;
                    opacity:1;}
                    
.randomImage:hover{-webkit-transform: scale(1.3);-ms-transform: scale(1.3);transform: scale(1.3); opacity:0;}

.randomItem:hover   {border-color: #009fdf;}

Your assistance in resolving this matter would be of immense help.

Thank you

Answer №1

After gaining a better understanding of your inquiry, I am ready to provide an answer. It appears that the opacity for hover effect is not working due to the element being out of view, preventing you from hovering on it directly. Instead, try hovering on another visible element, such as its parent. You can refer to the example below (same code snippet as earlier https://jsfiddle.net/4oxqw0uf/2/):

/*initial disappear*/
.hidden_text {
    ...
    opacity:0;
}
/*Making appear again on hover*/
.randomItem:hover .hidden_text {
    opacity:1;
}

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

Bootstrap is not merely compatible with HTML

Utilizing Flat UI's Bootstrap has not been successful when integrated with HTML. The code snippet in index.html looks like this: {% load staticfiles %} <html lang="ja"> <head> <meta charset="utf-8> <link rel="styleshee ...

Angular backslash is encoded

Experiencing the same issue as this individual: angularjs-slash-after-hashbang-gets-encoded The URL is getting encoded and not routing correctly, causing it to fall to the otherwise in my route config. I have not been able to identify the root cause yet, ...

In HTML, utilize the "clone" div class

Upon inspecting the element of my website, I have observed that the top-header div contains a duplicate. Why did this occur? How can I eliminate the clone and retain the original div top-header? Visit my site Below is the HTML code: <div id="top-h ...

What is the process for generating and launching an HTML page straight from LocalStorage?

Using JavaScript, HTML, CSS, and potentially PhoneGap if desired, is there a way to create and launch a basic html page directly from LocalStorage? I am looking for a personalized HTML page that can be accessed online on my iPod initially, but then offline ...

Struggling to follow the placement of elements within the treeview component

I have successfully implemented a method to track the positions of Div elements on my webpage. However, I am facing an issue with keeping track of the position of a div within a modal popup extender that contains a TreeView. The position is always reset to ...

Adjusting the style attributes for Material-UI Icons

I could use some assistance with changing the CSS property of MUI icons in order to assign a specific color when the icon is focused. I have implemented the icons in the header and am displaying different pages below them, so I would like to give each ac ...

Preventing Event Propagation in Angular HTML

I am encountering an issue with stopPropagation, and I need assistance with implementing it in HTML and TypeScript for Angular. The problem is that the dialog opens but also triggers a propagation. Below is my code snippet in HTML: <label for="tab-two ...

The HTML video controls in Safari take precedence over the window.name attribute

When using Safari 8.0.5, the controls attribute for the video element will change the value of window.name to "webkitendfullscreen". This is significant because I rely on using window.name to store client-side data in Safari's private mode, where loca ...

What steps do I need to take in order to resolve the routing issue with angular.js in my

Working on a mobile application with angular.js and firebase.js has been both exciting and challenging. Recently, I encountered an issue where the page refused to load properly because it was trying to access a peculiar URL file://file:///Users/patutinskij ...

Is there a way I can adjust the dimensions of this gallery?

Here is an example of what I am trying to achieve: http://codepen.io/moransh4/pen/aZOeNO How do I adjust the size of the images to be: width: 370px; height: 200px; Additionally, I want to display only 3 images per view? Ultimately, I would like the lay ...

Issue with displaying the Bootstrap Autocomplete Input Dropdown

I've been struggling with this issue for hours now. Using Bootstrap 3, I am attempting to implement the bootstrap autocomplete input with ajax. The data is being retrieved successfully through Ajax, and I can confirm that. However, the dropdown menu i ...

Self-moving button container

I have a challenge involving a button and a sliding div. When the button is clicked, I want the div to slide. The problem arises when I place the button inside the sliding div - it ceases to slide. I understand the issue at hand, but I'm unsure of ho ...

Using HTML within a Material-UI Accordion component

I am attempting to display HTML content within an Accordion component. import {Accordion, AccordionDetails, AccordionSummary, Typography} from '@material-ui/core'; import { Badge } from 'reactstrap'; ... const buildAccordion = (f, i) ...

Animating the navbar with CSS transitions

https://i.sstatic.net/cV3X6.png Seeking advice on adding a transition effect to my navbar. Specifically, I'd like to have a colored background appear below each link when hovered over. For example, when hovering over "HOME," a yellow color should dis ...

Use sed to extract integers from HTML based on various criteria

Before we continue, I must confess: I realize using regex to parse HTML is generally frowned upon, but if Chuck Norris can do it, why can't I? ;) My goal is to extract specific data from this HTML page: http://pastebin.com/unAifctF based on thre ...

Applying a margin to a CSS div at the bottom may cause it to not

I'm struggling to achieve the desired outcome with my layout: https://i.stack.imgur.com/CvLFl.png I have successfully replicated the image, but only when my div is not floating on the page (without margin applied and without using position: absolute ...

How can I create dynamic tabs using Tailwind CSS?

I am looking to create an animated tab using React and Tailwind CSS. Here is the code I have so far: import React from 'react' import clsx from 'clsx' export const Modal = () => { const [theme, setTheme] = React.useState<' ...

A guide on using Regular Expression to swap out every character with *

Recently, I came across a text that says: s = bluesky My aim is to transform it into s = ******* (with the same number of '*' as the number of characters). I have been on the lookout for a Python regular expression to achieve this. Update 1: ...

Trigger a click event on a div element that is nested within a form

Having trouble displaying an alert when clicking on a disabled button because the user needs to first click on a terms checkbox. Here's my jQuery code: $('#divButton').on("click", function() { if ($('#buybutton').prop('d ...

Unable to trigger onclick event for creating a new title

I'm currently working on a text generator project using JavaScript. My goal is to create a function that saves the selected text from a dropdown menu and displays it as the page title when the "Generate" button is clicked. The issue I'm facing i ...