A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.w3resource.com/html-css-exercise/css-properties/animation-iteration-count-answer.php below:

Website Navigation


CSS Properties: How to play the animation two times?

CSS Properties: How to play the animation two times?Last update on February 15 2024 10:04:24 (UTC/GMT +8 hours)

Go to Exercise page

Solution:

HTML Code:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" /><!-- Declare character encoding -->
<title>How to play the animation two times</title><!-- Set the title of the HTML document -->
</head>
<body>
<div class="animation">
<div class="w3r">
w3resource Tutorial
</div>
</div>
<style type="text/css"> /* CSS style start*/
.w3r {
color: white; /* Set text color */
float: left; /* Float the text to the left */
margin-right: 2%; /* Set right margin */
font-size: 20px; /* Set font size */
}
.animation {
background-color: #CC3333; /* Set background color */
height: 50px; /* Set height */
width: 100%; /* Set width */
overflow: hidden; /* Hide overflow content */
}
div {
width: 100px; /* Set width */
height: 100px; /* Set height */
background: #33FFFF; /* Set background color */
position: relative; /* Set position to relative */
-webkit-animation: move 5s infinite; /* Chrome, Safari, Opera */ /* Apply animation to Webkit browsers */
-webkit-animation-iteration-count: 5s; /* Chrome, Safari, Opera */ /* Set iteration count for Webkit browsers */
animation: move 5s infinite; /* Apply animation */
animation-iteration-count: 2; /* Set iteration count for animation */
}
/* Chrome, Safari, Opera */
@-webkit-keyframes move {
    from {top: 0px;} /* Define initial position */
    to {top: 200px;} /* Define final position */
}

@keyframes move {
    from {top: 0px;} /* Define initial position */
    to {top: 200px;} /* Define final position */
}
</style>
</body>
</html>

Explanation:

Live Demo:

See the Pen animation-iteration-count-answer by w3resource (@w3resource) on CodePen.

See the solution in the browser

Supported browser

Go to Exercise page

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4