Categories

How to create SVG animation

Ammy Brown December 25, 2017
Rating: 5.0/5. From 2 votes.
Please wait...

Have you heard about SVG images? SVG is Scalable Vector Graphics, which defines the graphics in XML format. The SVG image does not lose its quality if it is zoomed or resized. Unlike the other formats, SVG image could be easily animated with the help of CSS. To do that, follow a few simple steps:

  1. Choose an image you wish to animate. Don’t pay attention to the image format. We will convert it to SVG further.

  2. The image is selected! We can do the next step now, and convert it to SVG format. You can find a great variety of online SVG image converters on the Internet.We are going to use AConvert.com converter.

    • Converter page looks this way:

      First of all, browse selected image from the computer or enter your image URL to the first field.

    • Select SVG from the Target form field.

    • This online tool allows you to change image dimensions. You can leave default image size or enter required dimensions to the Change image size to field.

    • Click Convert Now! button to start conversion.

    • Wait a minute and scroll down to the Conversion Results section and click Save button to save the result.

    • You will be redirected to the File information page. The output file can be downloaded to your computer or saved to an online storage services such as Google Drive or Dropbox.

  3. Open the saved file with any code editor on your computer. We recommend using NotePad++ or Sublime code editors.

  4. Copy the <svg> </svg> tags content.

  5. Paste this code to the div tag with a class you have added to your image:

    Where car is your class id.

  6. Now we can add animation to your SVG image. To do that use one of the online tools available, for example, CSS Animate.

    • Enter your div class name to the Class name field.

    • Select an effect for your element from the Elements popup.

    • Change animation settings in the Keyframes window. You can set up animation speed, element position and frame properties here.

    • To check the result you can click on Play button in Timeline window.

    • Click Copy Code button to save generated CSS code.

  7. Go back to your HTML file. Add <style> tag with copied css code to the <head> section in your HTML file.

  8. You can use additional CSS styles for your SVG animation. Add CSS code for background to the same <style> tag. Save the file and check the result.


Want to add SVG support to your WordPress website? Learn how to do this!

This entry was posted in Working with CSS, Working with HTML. Bookmark the permalink.

Submit a ticket

If you are still unable to find a sufficient tutorial regarding your issue please use the following link to submit a request to our technical support team. We'll provide you with our help and assistance within next 24 hours: Submit a ticket