【问题标题】:CSS3 animation No effectCSS3动画无效果
【发布时间】:2013-11-07 23:58:56
【问题描述】:

使用 CSS3、HTML5、ASP.NET MVC4 C#。 MS Visual Studio。

我有以下 CSS...

.animated{-webkit-animation-fill-mode:both;
      -moz-animation-fill-mode:both;
      -ms-animation-fill-mode:both;
      animation-fill-mode:both;
      -webkit-animation-duration:1s;
      -moz-animation-duration:1s;
      -ms-animation-duration:1s;
      -o-animation-duration:1s;
      animation-duration:1s;}
@-webkit-keyframes bounceInRight {
0% {
    opacity: 0;
    -webkit-transform: translateX(2000px);
}   60% {
    opacity: 1;
    -webkit-transform: translateX(-30px);
}

80% {
    -webkit-transform: translateX(10px);
}

100% {
    -webkit-transform: translateX(0);
}
}

@-moz-keyframes bounceInRight {
0% {
    opacity: 0;
    -moz-transform: translateX(2000px);
}

60% {
    opacity: 1;
    -moz-transform: translateX(-30px);
}

80% {
    -moz-transform: translateX(10px);
}

100% {
    -moz-transform: translateX(0);
}
}

@keyframes bounceInRight {
0% {
    opacity: 0;
    transform: translateX(2000px);
}

60% {
    opacity: 1;
    transform: translateX(-30px);
}

80% {
    transform: translateX(10px);
}

100% {
    transform: translateX(0);
}
}

img.bounceInRight {
-webkit-animation-name: bounceInRight;
-moz-animation-name: bounceInRight;
animation-name: bounceInRight;
}    

剃刀视图 sn-p 是...

<div class="row rowpadding">
        <div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
            @Html.Action("BlogTags", "Blog")
            @Html.Action("BlogMonths", "Blog")  
        </div>
        <div class="col-xs-9 col-sm-9 col-md-9 col-lg-9">
            <div class="row rowpadding">
                @foreach (var item in Model.BlogPosts)
                {
                    if(isFirst)
                    {
                        isFirst = false;
                    } else
                    {
                    <div class="col-xs-4 col-sm-4 col-md-4 col-lg-4 news-cata-div-size">
                        <div><img class="bounceInRight" src="~/Themes/Renray/Content/images/small-1.png" /></div>
                        <div><span class="News-item-Date">@item.CreatedOn.ToString("D")</span></div>
                        <div><a class="News-item-title" href="@Url.RouteUrl("BlogPost", new { SeName = item.SeName })">@item.Title</a></div>
                        <div class="post-body">
                           @Html.Raw((item.Body.Length > 200 ? item.Body.Substring(0,200) : item.Body))
                           <a href="@Url.RouteUrl("BlogPost", new { SeName = item.SeName })">
                               ...Read More?
                           </a>
                        </div>
                    </div>
                    }
                }

            </div>
        </div>
    </div>

我提供的视图 sn-p 很大的原因是因为我想让你们看到整个事情,因为您可能会注意到这是一个使用引导的响应式构建

至于问题,动画应该从右侧反弹图像的每次迭代(动态图像的视图代码仍然不完整,但这不相关)。

加载时发生的一切都没有,没有动画效果。我想知道你们是否能指出我做错了什么。

非常感谢!

【问题讨论】:

  • 您的 .animated 课程未包含在您的 Razor sn-p 中。这个类真的有用吗?
  • 好点,忘记加了,这个还要加什么元素?
  • 你的img,大概。
  • 是的,现在做得很好,真是个笨蛋
  • 将其作为答案发布并确认,詹姆斯欢呼!

标签: c# html css asp.net-mvc-4 twitter-bootstrap


【解决方案1】:

问题似乎是您的动画填充模式和持续时间应用于.animated 类,该类未应用于您的 Razor 视图中的任何元素。

要解决此问题,只需将此类添加到您的 img 元素:

<img class="animated bounceInRight"
     src="~/Themes/Renray/Content/images/small-1.png" />

或者,合并您的 .animatedbounceInRight 类:

img.bounceInRight {
    -webkit-animation-fill-mode:both;
    moz-animation-fill-mode:both;
    -ms-animation-fill-mode:both;
    animation-fill-mode:both;
    -webkit-animation-duration:1s;
    -moz-animation-duration:1s;
    -ms-animation-duration:1s;
    -o-animation-duration:1s;
    animation-duration:1s;
    -webkit-animation-name: bounceInRight;
    -moz-animation-name: bounceInRight;
    animation-name: bounceInRight;
}  

【讨论】:

    猜你喜欢
    • 2012-06-19
    • 2020-08-11
    • 2015-07-09
    • 1970-01-01
    • 1970-01-01
    • 2015-01-11
    • 2015-02-20
    • 1970-01-01
    • 2017-04-28
    相关资源
    最近更新 更多