stern15
stern15

Reputation: 47

Cant run a css animation

I want to make the animation .logo to spin 360 degree ,its an image...any help please?

.logo {
  top:35%;
  left:70%;
  position: absolute;
  -webkit-animation-name: spin;
  -webkit-animation-duration: 5000;
  -webkit-animation-iteration-count: infinite;
  -webkit-animation-timing-function: ease-in;

}
@-webkit-keyframes spin {
  0%{ -webkit-transform: rotate(0deg);}
  100%{ -webkit-transform: rotate(360deg);}
}
nav ul {
  -webkit-font-smoothing:antialiased;
  text-shadow:0 1px 0 black;
  background: #bcab98;
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
}
nav li {
  float: left;
  margin: 0;
  padding: 0;
  position: relative;
  min-width: 25%;
}
nav a {
  background: #ddd;
  color: #444;
  display: block;
  font: bold 16px/50px sans-serif;
  padding: 0 25px;
  text-align: center;
  text-decoration: none;
  -webkit-transition: all .25s ease-in;
  -moz-transition: all .25s ease-in;
  -ms-transition: all .25s ease-in;
  -o-transition: all .25s ease-in;
  transition: all .25s ease-in;
}
nav a:hover{
  text-decoration: underline;
}
nav li:hover{
  text-decoration: none;
}
nav .dropdown1:after {
  content: ' ▶';
}
nav .dropdown1:hover:after{
  content:'\25bc';
}
nav .dropdown2:after {
  content: ' ▶';
}
nav .dropdown2:hover:after{
  content:'\25bc';
}


nav li:hover a {
  background: #ccc;
}
nav li ul {
  float: left;
  left: 0;
  opacity: 0;
  position: absolute;
  top: 35px;
  visibility: hidden;
  z-index: 1;
  -webkit-transition: all .25s ease;
  -moz-transition: all .25s ease;
  -ms-transition: all .25s ease;
  -o-transition: all .25s ease;
  transition: all .25s ease;
}
nav li:hover ul {
  opacity: 1;
  top: 50px;
  visibility: visible;
}
nav li ul li {
  float: none;
  width: 100%;
}
nav li ul a:hover {
  background: #bbb;
}
.drop_down_menu_for_cafe:after, .cf:before {
  content:"";
  display:table;
}
.cf:after {
  clear:both;
}
.cf {
  zoom:1;
}
<nav>
  <ul class="drop_down_menu_for_cafe">
    <li><a class="dropdown1" href="#"> Coffee Menu </a>
      <ul>
        <li><a href="file:///Users/semasuka/cafe-latte/Cappuccino.html"> Cappuccino coffee </a></li>
        <li><a href="#"> Expresso coffee  </a></li>
        <li><a href="#"> Black coffee </a></li>
      </ul>
    </li>
    <li><a class="dropdown2" href="#"> Tea </a>
      <ul>
        <li><a href="#"> Green tea </a></li>
        <li><a href="#"> Black tea </a></li>
        <li><a href="#"> Dark tea </a></li>
      </ul>
    </li>

    <li><a class="about" href="#"> About </a></li>
    <li><a class="contacts" href="#"> Contacts </a></li>
  </ul>
</nav>
<img  src="lattee.jpg" alt="latte_coffee" width="1180px" height="550px">
<span class="logo"><img class="logo" name="logo" src="coffee-logo.jpg" alt="latte_logo" width="200px" height="200px"></span>

Upvotes: 1

Views: 42

Answers (2)

Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

Reputation: 167182

Use this way. You are not putting all the vendor prefixes and the duration should have units: 5000ms or 5s:

.element-animation {
  animation: animationFrames linear 4s;
  animation-iteration-count: infinite;
  transform-origin: 50% 50%;
  -webkit-animation: animationFrames linear 4s;
  -webkit-animation-iteration-count: infinite;
  -webkit-transform-origin: 50% 50%;
  -moz-animation: animationFrames linear 4s;
  -moz-animation-iteration-count: infinite;
  -moz-transform-origin: 50% 50%;
  -o-animation: animationFrames linear 4s;
  -o-animation-iteration-count: infinite;
  -o-transform-origin: 50% 50%;
  -ms-animation: animationFrames linear 4s;
  -ms-animation-iteration-count: infinite;
  -ms-transform-origin: 50% 50%;
  width: 50px; line-height: 50px; background: #99f; text-align: center;
}
@keyframes animationFrames {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
@-moz-keyframes animationFrames {
  0% {
    -moz-transform: rotate(0deg);
  }
  100% {
    -moz-transform: rotate(360deg);
  }
}
@-webkit-keyframes animationFrames {
  0% {
    -webkit-transform: rotate(0deg);
  }
  100% {
    -webkit-transform: rotate(360deg);
  }
}
@-o-keyframes animationFrames {
  0% {
    -o-transform: rotate(0deg);
  }
  100% {
    -o-transform: rotate(360deg);
  }
}
@-ms-keyframes animationFrames {
  0% {
    -ms-transform: rotate(0deg);
  }
  100% {
    -ms-transform: rotate(360deg);
  }
}
<div class="element-animation">Logo</div>

Upvotes: 0

CoderPi
CoderPi

Reputation: 13211

The problem is that you have -webkit-animation-duration: 5000; instead of -webkit-animation-duration: 5000ms;:

... and you might also want to support other browsers

.logo {
  top: 35%;
  left: 70%;
  position: absolute;
  -webkit-animation-name: spin;
  -webkit-animation-duration: 5000ms;
  -webkit-animation-iteration-count: infinite;
  -webkit-animation-timing-function: ease-in;
  -moz-animation-name: spin;
  -moz-animation-duration: 5000ms;
  -moz-animation-iteration-count: infinite;
  -moz-animation-timing-function: ease-in;
  -ms-animation-name: spin;
  -ms-animation-duration: 5000ms;
  -ms-animation-iteration-count: infinite;
  -ms-animation-timing-function: ease-in;
}
@-moz-keyframes spin {
  from {
    -moz-transform: rotate(0deg);
  }
  to {
    -moz-transform: rotate(360deg);
  }
}
@-webkit-keyframes spin {
  from {
    -webkit-transform: rotate(0deg);
  }
  to {
    -webkit-transform: rotate(360deg);
  }
}
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
nav ul {
  -webkit-font-smoothing: antialiased;
  text-shadow: 0 1px 0 black;
  background: #bcab98;
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
}
nav li {
  float: left;
  margin: 0;
  padding: 0;
  position: relative;
  min-width: 25%;
}
nav a {
  background: #ddd;
  color: #444;
  display: block;
  font: bold 16px/50px sans-serif;
  padding: 0 25px;
  text-align: center;
  text-decoration: none;
  -webkit-transition: all .25s ease-in;
  -moz-transition: all .25s ease-in;
  -ms-transition: all .25s ease-in;
  -o-transition: all .25s ease-in;
  transition: all .25s ease-in;
}
nav a:hover {
  text-decoration: underline;
}
nav li:hover {
  text-decoration: none;
}
nav .dropdown1:after {
  content: ' ▶';
}
nav .dropdown1:hover:after {
  content: '\25bc';
}
nav .dropdown2:after {
  content: ' ▶';
}
nav .dropdown2:hover:after {
  content: '\25bc';
}
nav li:hover a {
  background: #ccc;
}
nav li ul {
  float: left;
  left: 0;
  opacity: 0;
  position: absolute;
  top: 35px;
  visibility: hidden;
  z-index: 1;
  -webkit-transition: all .25s ease;
  -moz-transition: all .25s ease;
  -ms-transition: all .25s ease;
  -o-transition: all .25s ease;
  transition: all .25s ease;
}
nav li:hover ul {
  opacity: 1;
  top: 50px;
  visibility: visible;
}
nav li ul li {
  float: none;
  width: 100%;
}
nav li ul a:hover {
  background: #bbb;
}
.drop_down_menu_for_cafe:after,
.cf:before {
  content: "";
  display: table;
}
.cf:after {
  clear: both;
}
.cf {
  zoom: 1;
}
<nav>
  <ul class="drop_down_menu_for_cafe">
    <li><a class="dropdown1" href="#"> Coffee Menu </a>
      <ul>
        <li><a href="file:///Users/semasuka/cafe-latte/Cappuccino.html"> Cappuccino coffee </a>
        </li>
        <li><a href="#"> Expresso coffee  </a>
        </li>
        <li><a href="#"> Black coffee </a>
        </li>
      </ul>
    </li>
    <li><a class="dropdown2" href="#"> Tea </a>
      <ul>
        <li><a href="#"> Green tea </a>
        </li>
        <li><a href="#"> Black tea </a>
        </li>
        <li><a href="#"> Dark tea </a>
        </li>
      </ul>
    </li>

    <li><a class="about" href="#"> About </a>
    </li>
    <li><a class="contacts" href="#"> Contacts </a>
    </li>
  </ul>
</nav>
<img src="lattee.jpg" alt="latte_coffee" width="1180px" height="550px">
<span class="logo"><img class="logo" name="logo" src="coffee-logo.jpg" alt="latte_logo" width="200px" height="200px"></span>

Upvotes: 2

Related Questions