Accelerate blinking timer by utilizing CSS3 animations

I'm currently developing a quiz application that includes a timer counting down from 10 seconds to 0 seconds. As the timer reaches closer to 0 seconds, I am looking to implement a feature where my text blinks faster and faster. Additionally, I would like the transition time for this effect to start at 2 seconds when the timer is around 10 seconds and decrease as less time remains.

Is there a CSS3 solution available to achieve this effect?

Answer №1

To create a dynamic animation, you can define different keyframes with decreasing durations for each keyframe.

div {
    font-size: 40px;
    -webkit-animation: blink 10s 2s;
    animation: blink 10s 2s;
}

@-webkit-keyframes blink {
    0%  {color: blue;}
   10%  {color: yellow;}
   20%  {color: blue;}
   29%  {color: yellow;}
   38%  {color: blue;}
   46%  {color: yellow;}
   54%  {color: blue;}
   61%  {color: yellow;}
   68%  {color: blue;}
   74%  {color: yellow;}
   80%  {color: blue;}
   85%  {color: yellow;}
   90%  {color: blue;}
   92%  {color: yellow;}
   94%  {color: blue;}
   96%  {color: yellow;}
   98%  {color: blue;}
  100%  {color: yellow;}
 }

@keyframes blink {
    0%  {color: blue;}
   10%  {color: yellow;}
   20%  {color: blue;}
   29%  {color: yellow;}
   38%  {color: blue;}
   46%  {color: yellow;}
   54%  {color: blue;}
   61%  {color: yellow;}
   68%  {color: blue;}
   74%  {color: yellow;}
   80%  {color: blue;}
   85%  {color: yellow;}
   90%  {color: blue;}
   92%  {color: yellow;}
   94%  {color: blue;}
   96%  {color: yellow;}
   98%  {color: blue;}
  100%  {color: yellow;}
 }
<div>TEST</div>

Answer №2

If you're implementing a CSS animation that includes the "blink" effect, you have the option to adjust the timing and speed. By utilizing keyframes with specified opacity values at different percentages, you can create this blinking animation. Additionally, incorporating CSS timing-functions like "ease-in" and "ease-out" helps control the pace of the animation. For more customization, consider exploring custom bezier timing functions for precise adjustments: https://developer.mozilla.org/en-US/docs/Web/CSS/animation-timing-function.

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

Tips on adjusting the default width of the React player interface

I'm currently utilizing react-player to display a video in my app. The default width it comes with is not responsive, and applying CSS didn't prove to be effective. import ReactPlayer from 'react-player'; <ReactPlayer url="https:// ...

Background image not visible on Firefox and Chrome when using a DIV element

I'm encountering an odd issue where my DIV background isn't showing up in Firefox and Chrome, but it looks fine in IE. I've searched on several places like Stackoverflow for solutions to this problem, but none of them have worked for me so f ...

Calculate the total number of vacation days not including holidays and weekend days

Looking for help with a program I've created to calculate total vacation days, excluding weekends and national holidays. Successfully excluded weekends, but struggling with how to ignore national holidays in the calculation. The program is built usin ...

Creating HTML code from a multidimensional array is a useful skill to

I am looking to use PHP to generate HTML code similar to the following: <li id="821">Accessories for tablets and cell phones <ul> <li id="426">Cell Phone Accessories <ul> <li id="675">Stands and Docks</ ...

Connecting onClick event to a dynamically created div using Dojo

While working with dojo 1.9.2, I encountered an issue when trying to add an onClick function to a dynamically created piece of HTML code like so: clickableDiv = "<div data-dojo-attach-point=\"testBtn\">Click Me!</div>"; self.racks.in ...

Having trouble locating the search bar element on Walmart's website?

I'm currently working on a bot that needs Selenium to interact with the search bar on Walmart's website, where it will input the name of a specific product and perform a search. However, I've encountered an issue where no matter what method ...

Using jQuery to Toggle Visibility of Table Rows

I'm facing a challenge in creating a basic table layout where all the table rows are initially hidden when the document loads. The goal is to display specific rows when a corresponding button is clicked, but my current implementation doesn't seem ...

Flex items refusing to wrap in Firefox

I am facing an issue with my layout setup in different browsers. When I have a list of divs inside a flex div, it displays correctly in Chrome: However, in Firefox, it only shows a horizontal scroll with one line. Is there a way to prevent the forced hor ...

Adding multiple text as label and sublabel in a React MUI Tooltip can be achieved by utilizing the appropriate

I'm struggling to incorporate a MaterialUI Tooltip into my React application with two separate text lines. The first line should serve as the main title, while the second line functions as a sublabel. In this screenshot provided, you can see where I ...

Maximizing HTML5 Game Performance through requestAnimationFrame Refresh Rate

I am currently working on a HTML5 Canvas and JavaScript game. Initially, the frames per second (fps) are decent, but as the game progresses, the fps starts decreasing. It usually starts at around 45 fps and drops to only 5 fps. Here is my current game loo ...

How to access HTML content in Python web scraping with a delay?

Currently, I am using Python to scrape the HTML from this site: Upon accessing the webpage, you'll notice that the content changes within a few seconds. This page displays the latest posts on a forum, and my goal is to create a Discord bot that can s ...

Use a foreach loop to iterate over an array of dates and display them in individual tables

I am currently working on structuring my foreach loop to iterate through all the dates in my time stamp arrays. The goal is to display the results in 5 separate tables, each pertaining to one of the dates. Below is the function I've implemented to re ...

Spacing between products in Woocommerce product list

Welcome to my website! Check it out here: I am facing an issue with a long margin at the bottom of my woocommerce product list. I have tried using CSS to change it as shown below: .woocommerce .products ul, .woocommerce ul.products { margin-bot ...

Why is my HTML5 class unable to locate the contents of my observable array?

Any help would be greatly appreciated. I've been coding for over fifty years, but I'm relatively new to JavaScript, HTML, and knockout. This project seems promising if I can just get it to function correctly. What follows is one of the many appro ...

Prevent Click Event on Angular Mat-Button

One of the challenges I'm facing involves a column with buttons within a mat-table. These buttons need to be enabled or disabled based on a value, which is working as intended. However, a new issue arises when a user clicks on a disabled button, resul ...

How to position a static element using CSS

I'm trying to align an image in the center of the screen, but I've run into some trouble. Typically, this is easy by setting the width of a div and using margin: auto;. However, I also need the div to have the position: fixed; property, which see ...

What is the best way to enlarge the image to a specific percentage?

Although I have never programmed in HTML or worked on web projects before, I am currently using a git repository where the project is client-server. This means I need to modify the code to suit my requirements, which includes working with HTML. My problem ...

HTML 5 Video VTT File: A must-have for optimal video playback

Having trouble getting the subtitle.vtt file to load on Chrome with this code. Can anyone offer any insights? <div id="videoKilledTheRadioStar"> <video id="Tutorial" width="420" autoplay controls> <source src="videos/shaco.mp4" type="vi ...

A step-by-step guide on utilizing img src to navigate and upload images

I would like to hide the input type='file' element with id "imgInp" that accepts image files from users. Instead, I want them to use an img tag to select images when they click on a specific img tag. How can this be achieved using jQuery? Here i ...

Looking to transform a PHP output value

I have a form with checkbox input, and a hidden 'sibling' input attached to it, in order to generate values of either '0' or '3' based on the checkbox status. When unchecked, the value is '0', and when checked, the ...