动画不会运行

时间:2014-04-05 00:57:37

标签: css sass haml css-animations

我正在尝试在scss中运行一些动画,但我遇到了困难。在chrome dev工具中,它显示我的元素具有正确的动画集,我甚至将关键帧规则粘贴到codepen并在那里尝试并且它有效,但是当我在我的网站中运行它时它不起作用。我已经坚持了几个小时。

这是一个小提琴演示:http://jsfiddle.net/58xrZ/1/

这是用Scss和HAML编写的,如下所示

ul.tab-selection {
      width: 38.338926174%;
      float: right;
      position: relative;
      min-height: 20em;

      li {
        text-align: center;
        height: 6em;
        width: 6em;
        border-radius: 50%;
        position: absolute;

        &:first-child {
          background : radial-gradient(50% 50%, circle farthest-corner, rgba(98, 78, 44, 1) 0%, rgba(98, 78, 44, 0.66) 85.3%, rgba(98, 78, 44, 0.6) 100%);
          background : -moz-radial-gradient(50% 50%, circle farthest-corner, rgba(98, 78, 44, 1) 0%, rgba(98, 78, 44, 0.66) 85.3%, rgba(98, 78, 44, 0.6) 100%);
          background : -webkit-radial-gradient(50% 50%, circle farthest-corner, rgba(98, 78, 44, 1) 0%, rgba(98, 78, 44, 0.66) 85.3%, rgba(98, 78, 44, 0.6) 100%);
          top: 0;
          right: 50%;
          margin-right: -50px;      
          animation-name: first;
          animation-duration: 3s;
          -webkit-animation-name: first;
          -webkit-animation-duration: 3s;
          a {
            width: 4em;
            padding: 2em 1em
          }
        }

        &:not(:first-child){
          bottom: 1.5em;
        }


        &:nth-child(2) {
          background: radial-gradient(50% 50%, circle farthest-corner, rgba(121, 85, 48, 1) 0%, rgba(121, 85, 48, 0.66) 85.3%, rgba(121, 85, 48, 0.6) 100%);
          background: -moz-radial-gradient(50% 50%, circle farthest-corner, rgba(121, 85, 48, 1) 0%, rgba(121, 85, 48, 0.66) 85.3%, rgba(121, 85, 48, 0.6) 100%);
          background: -webkit-radial-gradient(50% 50%, circle farthest-corner, rgba(121, 85, 48, 1) 0%, rgba(121, 85, 48, 0.66) 85.3%, rgba(121, 85, 48, 0.6) 100%);
          filter: progid:DXImageTransform.Microsoft.Alpha(Stlye=2);
        }

        &:last-child {
          background : radial-gradient(50% 50%, circle farthest-corner, rgba(111, 68, 44, 1) 0%, rgba(111, 68, 44, 0.66) 85.3%, rgba(111, 68, 44, 0.6) 100%);
          background : -moz-radial-gradient(50% 50%, circle farthest-corner, rgba(111, 68, 44, 1) 0%, rgba(111, 68, 44, 0.66) 85.3%, rgba(111, 68, 44, 0.6) 100%);
          background : -webkit-radial-gradient(50% 50%, circle farthest-corner, rgba(111, 68, 44, 1) 0%, rgba(111, 68, 44, 0.66) 85.3%, rgba(111, 68, 44, 0.6) 100%);
          filter: progid:DXImageTransform.Microsoft.Alpha(Stlye=2);
          right: 0;
          a {
            left: 3px;
            padding: 2em 1em;
          }
        }

        a {
          position: absolute;
          right: 0;
          left: 0;
          top: 0;
          font-family: 'Lora', serif;
          color: #AE843D;
          text-shadow: 0 -1px 0 black;
          padding: 1.5em 1em;

          &:hover {
            color: #3D6F51;
          }
        }
      }
    }

和在Haml

%ul.tab-selection
  %li.active.current-projects
    %a{ :href => '#current-projects', 'data-toggle' => 'tab' }
      Current
      %br Projects
  %li.secret
    %a{ :href => '#secret', 'data-toggle' => 'tab' }
      The
      %br
      Secret Shop
  %li.favorite
    %a{ :href => '#favorite', 'data-toggle' => 'tab' }
      Favorite
      %br Links

1 个答案:

答案 0 :(得分:1)

您需要将关键帧放在CSS的底部。您还需要拥有@keyframes动画的浏览器前缀版本,以便当您说-webkit-animation:...时,它实际上将转到@-webkit-keyframes

Demo

它可能只适用于CodePen,因为它使用的是前缀,它会自动添加前缀