Is CSS Transition smoothly easing in, but not out?

On the image gallery of this website , I have applied transitions to the images, where they ease in (fade in), but revert back to their original state instantly when the mouse moves off the image. Is there a way to make the transition reverse when the mouse is taken off?

Answer №1

To ensure a smooth transition in the non-hovered state, make sure to include the transition property as shown below:

.gallery img {
    box-shadow: 7px 7px 13px 0px rgba(0,0,0,0.75);
    filter: grayscale(100%) blur(1px);
    transition: 1s;
}

The reason for this is that when the mouse is not hovering over the image, the :hover rules do not apply. Therefore, if the transition property is only declared under :hover, it will effectively cease to exist once you move the cursor away from the image.

Answer №2

Below is the solution for your query:

.gallery img:hover {
    filter: grayscale(0%);
    
}

/*Ensure to utilize transition in the image styling*/ 
.gallery img {
    box-shadow: 7px 7px 13px 0px rgba(0,0,0,0.75);
    filter: grayscale(100%) blur(1px);
    transition: 1s;
}
<div class="gallery"> <img src="https://sandbox.graphicandwebdesign.ca/karim-jamous/newsletter/pic4.jpg" width="250" height="250" alt="fourthpicture"> </div>

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 issue persists with Angular's overflow hidden not functioning properly, and similarly, the show password button is

I created a login page using Angular Material, but I'm facing some issues. The problem is that when I set the style overflow: hidden, the show password button stops working. Additionally, if I click the button twice, the webpage refreshes, which shoul ...

Switch the header from left to right movement for mobile devices

I am dealing with two headers in my layout <section> <header class="col-lg-9"> <!-- some content --> </header> <header class="col-lg-3"> <!-- some content --> </header> </section ...

Creating unique navigation bar elements

I'm currently working on an application and facing an issue with the navigation from the Component to NavbarComponent. If you'd like to check out the application, you can visit: https://stackblitz.com/github/tsingh38/lastrada The goal is to hav ...

What is the best method for retrieving the id from an <a> tag in HTML and passing it to a JSP

My dilemma involves a snippet of HTML code: <a href="mobile.jsp" id="s5" >Galaxy s5</a> <a href="mobile.jsp" id="iphone">Iphone 4S</a> <a href="mobile.jsp" id="xpr">Xperia</a> I am aiming to organize similar items on o ...

align text vertically over an image

I've come across this question many times, but none of the answers seem to solve my issue. My challenge is centered around aligning text on an image with regards to vertical positioning. Below is the code I'm working with: <div class="col-sm- ...

Fancybox causing issue with submit button functionality

When a link is clicked, I am triggering the opening of a submit button styled fancybox. The fancy box contains fields for username and password that need to be authenticated upon clicking the submit button (for now, the fancybox is just a submit button). ...

Emphasize user-entered text using HTML and CSS

Here's a scenario: a text paragraph is displayed alongside an input box. The user must type the same text into the input box as shown in the paragraph. I'm aiming to highlight the paragraph text in color as the user types, to demonstrate progres ...

Troubleshooting Bootstrap image alignment problem with columns on extra small screens

My website showcases screenshots of my software in a div element. Everything looks great on larger screens, but once I switch to a phone or resize the window, the images don't align properly, leaving empty space. Refer to the image below for clarifica ...

Implement a feature in JS/HTML where clicking on a button shifts a specific section of a row from one table to another while simultaneously deleting the remaining

I am facing an issue with two tables - addFriends and existingFriends. The addFriends table contains a button in the fourth column, which, upon clicking, should delete the corresponding row from that table and add it to the existingFriends table. Currentl ...

Can you please elaborate on how the CSS properties: -webkit-border-radius and border-radius are utilized?

https://i.sstatic.net/ILDTb.png What is the reason for having different values of 25px for -webkit-border-radius and border-radius in various positions? table.cal{ color: #064525c; border-spacing: 0; border: 3px solid black; -webkit-bor ...

You cannot use a colon ( : ) in HTML input text fields

How can I prevent a colon from being inserted into an input text field? In my code snippet, I have <input type="text"/> and I want to ensure that if the user types " : ", nothing appears in the input text field. Is there a way to achieve this using ...

Is using .htaccess a reliable method for securing a specific file on the server?

Running a classifieds website comes with its own set of challenges, one being the need for an administrator to have the ability to remove classifieds at their discretion. To address this issue, I have developed a simple function that allows me to specify t ...

What is the best way to use jQuery to access dynamic HTML elements?

I have created a dynamic table that allows users to add and delete rows. However, I am facing an issue with accessing the information inputted by the users for calculations because it seems to be inaccessible once dynamically added to the page. Below are ...

What could be the reason for justify-self: flex-start not positioning the div at the bottom of a column?

I want to display a div in three levels: header, content, and footer. The content can vary in height and the footer should always be at the bottom. Here is how I have implemented it: <div class="news-content-block"> <div class=" ...

Guide to adding content and icons to the top navbar on the right side using vue.js

In the process of developing a fixed top navbar, I encountered an issue while trying to add right side icons and additional content. The goal is to include two icons, as shown in this example: example link, along with profile and cart information on the ri ...

Bootstrap 3 with a left sidebar menu featuring subtle ghosting borders for a sleek and modern

Hello there! I have a bootstrap 3 sidebar that seems to be causing some issues in IE 11. Specifically, I am encountering a strange ghosting effect on the border of the sidebar. When the page initially loads, only the bottom edge of the sidebar is visible. ...

Having Issues with Cms Installation

I've been experimenting with a content management system that I plan to use for a project, but I encountered some errors. It seems like any "dynamic" elements are not displaying properly. Warning: mysqli::prepare() [mysqli.prepare]: (42S02/1146): Tab ...

Looking to Move the Image Up?

I've been experimenting with creating a grid layout where the bottom image will move up until it is 10px away from the image directly above it. However, no matter what I attempt, the spacing seems to be based on the tallest image rather than the one a ...

Guide to displaying highcharts using external json data for numerous series

Having an issue with using angularjs and highcharts with multiple series where the data is coming from an external JSON file. When trying to access the data with a for loop using data.data[i].data, it's not working properly. Can anyone offer assistanc ...

Exploring the beauty of ASCII art on a webpage

Having trouble displaying ASCII art on my website using a JavaScript function, the output is not as expected... This is how it should appear: https://i.sstatic.net/MCwPb.png And here is the code I am trying to implement for this purpose: function log ...