Transitioning the gradient on hover using CSS

I have looked through many other questions here, but I can't seem to find an answer to my issue. I have a div block with a :after CSS selector where I apply a gradient overlay on an image. When someone hovers over the div, I want a slightly different gradient overlay.

The hover effect is working and the gradient changes, but I am struggling to make the speed of this change smooth using the transition CSS property.

Below is my code snippet:

.fotka-box::after {
    /* Gradient background properties */
    
    -webkit-transition: all 1350ms ease-in-out;
    -moz-transition: all 1350ms ease-in-out;
    -o-transition: all 1350ms ease-in-out;
    transition: all 1350ms ease-in-out;
    
    display: block;
    position: absolute;
    top: 0;
    right: 0;
    height: 370px;
    max-height: 100%;
    left: 0;
    pointer-events: none;
    content: '';
}

.fotka-box:hover::after {
    /* Adjusted gradient for hover effect */
}

Can anyone provide guidance on what I might be doing wrong in implementing the transition effect? Any suggestions would be greatly appreciated.

PS: I am aware that I could use opacity, but I prefer changing the gradient color and style rather than transitioning from 0 opacity to 1.

Answer №1

Check out this awesome resource for creating gradient transitions using CSS:

Currently, gradients do not fully support transitions.

To achieve a fade-in effect with a background gradient, you must apply an opacity to the container element and transition the opacity property.

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

stop cascading style sheets from being overwritten

In my ASP.NET web forms project, I am utilizing Telerik controls. The Problem In one instance, I need to retrieve HTML data from the database, which includes a lot of CSS, images, and HTML content. Here is an excerpt of my code: <telerik:RadLabel ...

Padding for the doughnut chart in Chart.js canvas

My current setup includes a canvas featuring a doughnut chart created with chart.js enclosed in a div element that displays like this: https://i.sstatic.net/yy1e4.png The canvas has a red background to enhance visibility. Currently, the chart is centered ...

Position child divs at the center of the parent div

I am struggling to center 3 child divs inside a parent div that must remain at a width of 100%. Can someone help me figure out how to achieve this? .parent { width: 100%; border: 1px solid blue; } .child { float: left; borde ...

Adjust the position of an image to move it closer to the top using CSS

I have a fiddle where I am trying to adjust the position of an image (keyboard) to match a specific design. https://i.sstatic.net/flqCH.png In my fiddle, the keyboard image is slightly lower than the desired position shown in the design. I am looking for ...

When incorporating inline-block styling in dompdf, it may result in added space below the elements

One issue that arises when there are multiple elements with display:inline-block is that these elements can sometimes display with a margin below them after being rendered as a PDF: <div style="background-color:pink;"> <div style="background- ...

How come I am unable to adjust the padding of a hyperlink in a manner that it expands to fullscreen when hovered over?

My navigation bar currently displays links to other pages stacked vertically. When hovering over the links, they change background-color, but I want them to expand to full screen. I attempted adjusting the padding-left and padding-right, but it wasn' ...

How can I change the padding that is being inherited from "@ .MuiAlert-icon"?

Is there a method to override the padding inherited from "@ .MuiAlert-icon"? The Chrome inspector indicates that the current padding is set to 7px. .MuiAlert-icon { display: flex; opacity: 0.9; padding: 7px 0; font-size: 22px; ...

What could be causing this compatibility issue between IE and Chrome? It's strange that the Table is displaying correctly only in Chrome

Recently, I encountered a challenge with my code in Chrome and realized that it also needs to work in Internet Explorer. Can someone assist me in making it fully functional in IE? I suspect that there might be specific code adjustments needed for IE as th ...

Is there a way for me to select elements that don't have the class "class" and are an even

I've been utilizing CSS for various tasks, however, there is a particular situation where it doesn't seem to function correctly. My goal is to create a list similar to a spreadsheet, with each line alternating between light grey and slightly dar ...

Verify whether the div already includes a particular item

I am currently working on an angular project where I need a button to add a blockquote within a div, but only if the blockquote is not already present in the HTML structure. My initial approach was to search for the specific string <blockquote id=&apos ...

Adjusting the media query breakpoints based on the visibility of the side panel

I have been tasked with enhancing an already extensive React project by adding a 400px wide side panel that is only visible under certain conditions. Depending on the screen size, the side panel should either appear in the empty space to the right of the ...

Styling Images with Gradient using CSS

Looking to create a unique effect on an image by adding a radial gradient that seamlessly fades into the background color. Despite my efforts, I haven't been able to achieve this using filters and my current code is a bit messy. Here's what I ha ...

Is it possible to modify Bootstrap 4 variables using its own variables?

I am currently utilizing the latest Bootstrap 4 beta 2 and attempting to customize it by altering the variables to suit my preferences. Within my styles.scss file, I have included all necessary bootstrap imports: // Custom variables @import 'helpers ...

What is the best way to ensure that the text within Span children is properly laid out to match the width of the parent div tag?

This particular instance involves setting the width of the div tag to 200px and organizing all the span children to occupy the entire width of the parent div tag. If the first row is filled, the span tags should then flow into a second row. My attempt at ...

What is the best way to spin a paragraph in Bootstrap?

I've been attempting to rotate this div by 90 degrees, but for some reason, it refuses to cooperate. I've tried using various bootstrap classes with no success, and even plain CSS doesn't seem to have any effect on it. #socials { transf ...

Is there a way to showcase images next to each other within an array in Angular 8, like having 2 images in a row and then another 2 in the next row?

Here is the HTML code I created and tested: <div class="row"> <div *ngFor="let url of urls" class="col-md-6"> <img [src]="url" alt="Image not found" height="250px" width="350px" (click)="imageClick(url)"> </div> < ...

Combine two flex directions within a single container

Is it possible to achieve the following layout within a single container? I understand that using display: flex; justify-content: center, align-items:center can center all elements, but can I specify two of the divs to be displayed in a column rather than ...

Changing the Options for Page Size in Material Paginator

Firstly, here is my angular code: ts: @Component({ selector: 'app-dashboard', templateUrl: './dashboard.component.html', styleUrls: ['./dashboard.component.scss'] }) export class DashboardComponent implements OnInit, A ...

Add interactive buttons to an image that will appear when hovered over, while also darkening the

Is it possible to create an effect where the image darkens slightly when the mouse hovers over it, followed by buttons appearing on hover like in the image provided? Additionally, when hovering over a button, could it change color to red similar to the pic ...

Initial Row Defense Against Full Screen Websites

I am in the process of creating a webpage that spans 100% width using the foundation framework. Everything is going smoothly until I encounter an issue when trying to include a "div class="row" container. My goal is to have two images side by side, occupy ...