Keyframes for CSS3 animations

I've spent the past hour trying to figure out this issue. I rely on Notepad++ as my code editor, and I've been attempting to create a css3 animation without success. The problem lies in Notepad++ not recognizing the "@" symbol in "@-webkit-keyframes." While all other text is highlighted in blue, the "@" remains black. I've tried creating new files multiple times, but nothing seems to work. Here's my code:

HTML:

    <!DOCTYPE html>
    <html>
      <head>
        <title>Animation</title>
        <link href="stylesheetani.css" rel="stylesheet" type="text/css"/>
      </head>
      <body>
        <div id="change">
        </div>
      </body>
    </html>

CSS:

    #change {
      width: 100px;
      height: 100px;
      border: 2px solid black;
      -webkit-animation: changeColor 8s infinite;
    }

    @-webkit-keyframes changeColor {
      0% {background-color: blue;}
      25% {background-color: yellow;}
      50% {background-color: green;}
      75%{background-color: red;}
      100% {background-color: black;}
    }

Answer №1

After including the additional vendor prefixes, your code is now functioning correctly. See the demonstration below:

#modify {
  width: 100px;
  height: 100px;
  border: 2px solid black;
  -webkit-animation: modifyColor 8s infinite;
  -moz-animation: modifyColor 8s infinite;
  animation: modifyColor 8s infinite;
}

@-webkit-keyframes modifyColor {
  0% {background-color: blue;}
  20% {background-color: yellow;}
  40% {background-color: green;}
  60% {background-color: red;}
  80% {background-color: black;}
  90% {background-color: skyblue;} /* New keyframe added */
  100% {background-color: blue;}
}

@-moz-keyframes modifyColor {
  0% {background-color: blue;}
  20% {background-color: yellow;}
  40% {background-color: green;}
  60% {background-color: red;}
  80% {background-color: black;}
  90% {background-color: skyblue;} /* New keyframe added */
  100% {background-color: blue;}
}

@keyframes modifyColor {
  0% {background-color: blue;}
  20% {background-color: yellow;}
  40% {background-color: green;}
  60% {background-color: red;}
  80% {background-color: black;}
  90% {background-color: skyblue;} /* New keyframe added */
  100% {background-color: blue;}
}
<div id="modify"></div>

In addition to these changes, I adjusted the timing percentages and introduced a new keyframe for a smoother transition back to the starting blue color.

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

Show the form for user input

I have an HTML code for a form that requires input. Once the 'OK' button is clicked, the values are sent to a PHP script using $_POST. Is it possible to display the same form again if the input format is incorrect, but do so only within my PHP sc ...

Is it possible to use an Ajax callback function to add a select dropdown HTML to a table

I am currently in the process of using jQuery to append some HTML with the code provided below. My main objective is to select an option based on AJAX response data and create a select dropdown menu. However, the variable scope of sOut doesn't seem to ...

A guide to revealing/hiding a connected radio button using javascript or jquery

Despite the confusing title of my question, my goal is clear: When I select the radio button for text1, the corresponding subtext1 radio button should appear. Subsequently, when I click on text2's radio button, the subtext2 radio button will be displ ...

Learning to extract information from a JSON file with various key and value combinations

I am facing a challenge with my JSON data file, which contains UserIDs as keys and Passwords as values. My goal is to use JavaScript for validation by reading this JSON file. The structure of my JSON is as follows: IDsNPass = '[{"A":"A15"},{"B":"B15" ...

Sending data to a modal within a loop

I am looking to modify the functionality of my current table setup. Currently, the table is generated by iterating through all the samples passed to it via the context in views.py of my Django app, and this setup is working well. However, I want to imple ...

Is there a more efficient method to halt a jQuery animation plugin? Surely, there must be a more effective solution

After feeling under the weather for the past week and feeling incredibly bored, I decided to delve into the world of creating jQuery plugins. In just half an hour, I managed to put together a plugin that mimics the "wiggle" effect when pressing and holding ...

Issue with SVG compatibility in Mozilla Firefox

Just starting out with SVG and here is my code: <div style="width:650px;"> <svg xmlns="http://www.w3.org/2000/svg" version="1.1"> <rect width="640" height="200" style="fill:#ddd;"></rect> <polyline points="0 200,20 200, 40 200, ...

Contrasts between Flash and HTML5

Now that YouTube has transitioned from flash to HTML5, what are the unique features and functionalities of HTML5 that set it apart from flash? I am also curious to learn a more in-depth and intriguing aspect of HTML5 beyond what can be found through a sta ...

Tips for synchronizing the height of a scrollable list-group column with a neighboring column

Within my Bootstrap 4 layout, I have a column on the left that includes a dynamically generated .list-group, which could potentially contain numerous .list-group-items. On the right side, there is another column showcasing multiple cards inside a .row. Th ...

Is it possible to retrieve the pixel color of a mesh by clicking on it in JavaScript?

On the current page, we have a mesh loaded with TreeJS and displayed in a canvas: https://i.sstatic.net/j8Ztj.png Is there a way to retrieve the color of the point where a click occurs? I attempted a method suggested in this thread: Getting the color val ...

Assistance needed in handling a form with the use of $_POST and $PHP_SELF

Let me explain my goal in creating a webpage using HTML and PHP. The webpage will feature multiple forms to gather user inputs for future use. My plan is to reveal each form only after the previous one has been submitted. Here are the 3 forms: First name ...

Is it possible for jQuery UI Dialog to function similar to an iFrame?

Is there a way to set up my dialog box with a form so that when the form is submitted, only the dialog box changes instead of the browser location? ...

The datepicker on mobile devices fails to display the default text of dd/mm/yyyy

This JSP code uses Bootstrap5: <form action="" method="GET" class="row g-1 mb-3 "> <div class="col-lg-2 col-md-4 col-6 mb-2"> <input type="date" class="form-control" name=" ...

jQuery failing to recognize multiple selection form elements

<select class="js-example-basic-multiple categories form-control" name="categories[]" style="width: 100%" multiple="multiple"> <option value=""></option> <option value="fresher">fresher</option> <option value=" ...

Use jQuery to transition the "position:absolute" element from top to bottom and create a smooth fade effect

When the "anim" class is activated, it should smoothly fade in from top to bottom Here is the corresponding HTML code: <div class="col-xs-6" style="position:relative;"> <img src="<?= site_url('assets/image/right_bg.png'); ?>" ...

What is the best way to resolve the error message: "__init__() received an unexpected keyword argument 'book_category'"?

I'm currently working on inputting book data and storing it in my database using Django to create a web library. However, I keep encountering the following error: init() got an unexpected keyword argument 'book_category' The issue seems t ...

Endless scrolling results in a full loading rather than a step-by-step one

I'm currently working on implementing infinite scrolling on my website by following a tutorial I came across. However, instead of displaying only a few items at a time and allowing for continuous scrolling, the page loads up with all items at once. I& ...

Incorporating a new Autodesk Forge extension

Hey there! I'm currently working on integrating a forge extension into my viewer, but I seem to have missed something along the way. I've been following this helpful guide: Here's the code snippet that I'm using: <body> < ...

Delete an entry from the list

I have a fully functional Ajax call and function that fills up a datalist. This datalist is utilized to choose from a limited list and add it to a UL element on the page. Once an option is added from the datalist to the actual list, I aim to eliminate that ...

Tips for enabling selection of list items in an input tag

Below is the code I have written to create an InputFilter. MyFilter = function(args) { var dataUrl = args.url; var divID = args.divID; var div = document.getElementById(divID); var myTable = '<input type="text" id="myInput" on ...