Is it possible to finely tune the animation properties of a CSS element?

I'm facing an issue with my current code:

transition: all 0.35s;
transition-delay: 0.25s;
transition-timing-function: cubic-bezier(.79,0,.46,1);

Adding more properties to animate is causing problems, so I'm exploring a new approach like this:

transition: transform 0.35s/*duration*/ 0.25s /*delay*/ cubic-bezier(.79,0,.46,1),
            opacity 0.25s/*duration*/ 1s /*delay*/ ease-in ;

I've considered using shorthand properties but haven't found the right combination yet.

Answer №1

Indeed, what you're looking for is a css animation, not just a transition. While transitions help create a smooth shift between states, animations provide more intricate behaviors by altering css properties.

The basic structure would be something like this:

element {
  animation-name: yourAnimationName;
  animation-timing-function: cubic-bezier(.79,0,.46,1);
  animation-delay: 0.25s;
}

@keyframes yourAnimationName {
   // specify which css properties to animate
}

You can define keyframes with from and to values:

@keyframes yourAnimationName {
    from { background-color: red; }
    to { background-color: yellow; }
}

Alternatively, you can have multiple keyframes using percentages to indicate the progress of the animation:

@keyframes example {
    0%   {background-color: red;}
    25%  {background-color: yellow;}
    50%  {background-color: blue;}
    100% {background-color: green;}
}

If you use keyframes with percentage values, you may not need the cubic-bezier timing function.

For further information on css animations, I suggest checking out this resource HERE.

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

What is the best way to place my modal popup above my text content?

I don't understand why my .btn tag is showing up above my modal on popup. I've tried adjusting the z-index and setting position to relative, but nothing seems to be working as expected. Check out my code below where I have 4 boxes that trigger a ...

Is there a way to preserve the original color format without converting it to RGB

When applying a hsl color in JavaScript, it ends up being converted to RGB instead of staying as an HSL color. document.body.style.backgroundColor = "hsl(0,100%,50%)" document.body.style.backgroundColor; // "rgb(255, 0, 0)" I wanted to set an HSL color a ...

Can flexbox be constrained to a grid while wrapping text?

Admiring the way this design wraps seamlessly while still maintaining aligned boxes on both sides, creating a visually appealing and fully utilized space. <head> <style> * { padding: 0px; margin: 0px; text-transform: none; font-style ...

I'm looking for the location of Angular Materials' CSS directives. Where can I find them?

Currently, I am using components from https://material.angularjs.org/latest/ for a searcher project. One specific component I am working with is the md-datepicker, and I would like to implement some custom styles on it such as changing the background colo ...

Navigating on a page using anchor tags within a dropdown menu

I'm in the process of creating a top navigation bar with dropdown functionality that appears when hovering over certain navigation items. Here's how it currently looks: $(document).ready(function(){ $('[data-toggle="tooltip"]').t ...

What could be causing my mobile page to require two scrolls?

I've encountered a peculiar issue where users need to scroll twice or the page gets stuck on mobile devices that are less than 600px wide. I've attempted the following solutions with no success. I am a complete novice, so please excuse my lack of ...

Enhance this piece of code with JavaScript features

I recently implemented a scrolling script on my website that I found at this link: http://blog.waiyanlin.net/example/jquery/flyingtext.html. However, the animation currently scrolls from left to right and I would like it to scroll from right to left inst ...

The distance separating the top navigation bar from the sub-navigation menu

I have designed a navigation menu with a subnavigation section, view it on JSFiddle with subnavigation. My challenge is to create a 1px solid white separation between the top navigation (with yellow background) and the subnavigation (with red-colored backg ...

"Render Failure" JavaScript and CSS files

I'm encountering a peculiar issue while attempting to load certain JS and CSS files. Within my ASP.NET MVC Web Project, I have an Index.html file where I've specified the loading of script files. It's worth noting that I have modified the U ...

Display a unique and unconventional image as a dynamic full-screen background, ensuring the entire image is visible using React/RedwoodJS

Looking for a somewhat unusual solution here - I want to use an image as a background with all edges of the picture visible at all times. Typically, I would use the "cover" setting for this, but that doesn't achieve what I need (image included). After ...

Google Charts displays currency values without decimal places

I've been working on a project that involves the Google Visualization API. I successfully formatted the y-axis values of my chart to display in currency using vAxis: {format: 'currency'} in the options. However, I'm struggling to figure ...

What is the process for implementing transitions using SASS?

When the pointer hovers over it, the transition effect kicks in smoothly. However, it reverts back to its original size abruptly when the mouse pointer is no longer hovering over it. What I aim for is for the cardLink to scale smoothly ...

Code timer for HTML redirection

Some time ago, I created this code to display random events on my website. While the code functions well, I now wish to incorporate a timer. I envision that when a user refreshes or enters the page, they will be redirected initially and then redirected ag ...

What is the best way to extend an image to fill the width of a webpage?

Can you advise me on how to expand the image to fit the width of my webpage? If possible, could you take a look at this website: Poklanjam The specific image I am referring to is the one of the city on the left-hand side. What additional CSS code should ...

Struggling to remove the excess white space while working with Bootstrap 5

Trying to eliminate the white space visible in the image. Utilizing Bootstrap for my project, but still getting acquainted with it. My teacher suggested (without reviewing any code) that a container might be causing the issue. I disagree as the HTML contai ...

I'm looking for a method to trigger onChange() specifically on Internet Explorer using only JavaScript, HTML, and CSS without relying on jQuery

Looking for a way to utilize onChange() only on Internet Explorer using Javascript, HTML, CSS (No Jquery). My current code successfully sends the input to my function upon onChange(), but it seems to work smoothly on Chrome and not on IE. Is there a meth ...

Assistance is needed in creating a compact HTML website

I've designed a small PSD Mockup of an about page for my website. However, I lack the knowledge to code in HTML and CSS. Here is the current code snippet: index.html <html> <link rel=StyleSheet href="css.css" type="text/css"> <head&g ...

Adjust the cursor on an HTML5 Canvas while moving the mouse

My latest project involves creating a paint brush application using the Canvas Tag. I successfully changed the cursor when the mouse hovers over the canvas: <canvas id="draw" style="cursor: url(image/pencil.cur)"> However, I am now faced with the c ...

Transitioning the font in CSS does not appear to be functioning properly when

I am currently utilizing a CSS setup like this: .container { display: flex; align-items: center; } p { font-size: 10px; -webkit-transition: all 0.3s ease; -moz-transition: all 0.3s ease; -o-transition: all 0.3s ease; -ms-trans ...

Design elements - Responsive vertical images

I am facing an issue with resizing the slider I have on my website. Currently, it is set at 1200 x 400 pixels, and while the width adjusts correctly when the page is resized, the height remains fixed at 400px. I would like the height to resize proportional ...