【问题标题】:CSS3 shapes and animation - ArrowCSS3 形状和动画 - 箭头
【发布时间】:2013-09-24 17:30:55
【问题描述】:

如下图所示,我必须创建此图像并为其设置动画。我原本打算不为此实际使用图像,而是使用 CSS3 border-radius 来执行此操作。所以,下面的 HTML 和 CSS 就是我所在的位置。

我想要的动画是箭头应该从底部开始出现并沿着流向上移动继续显示,向右移动直到箭头指针结束。但我真的不确定我该怎么做。我必须支持浏览器IE8+、chrome、FF。

HTML:

<div class="years">
    <article>
        <figure>
            <div class="vrt-bar"></div>
            <div class="hrzt-bar"></div>
            <div class="arrow"></div>
        </figure>
    </article>
</div>

CSS:

.years article figure {
    height:auto;
    position:relative;
}
.years article figure .vrt-bar {
    width:34px;
    height:192px;
    behavior: url(css/PIE.htc);
    border-radius:25px 0 25px 25px;
    -webkit-border-radius: 25px 0 25px 25px;
    -moz-border-radius: 25px 0 25px 25px;
    float:left;
    background:#00b9d3;
    position:relative;

}
.years article figure .hrzt-bar {
    width:143px;
    height:32px;
    background:#00b9d3;
    margin-left:34px;
}
.years article figure .arrow {
    width: 0;
    height: 0;
    border-top: 25px solid transparent;
    border-bottom: 25px solid transparent;
    border-left: 25px solid #00b9d3;
    position:absolute;
    top:-10px;
    left:177px;

}

jsfiddle:http://jsfiddle.net/KgAe4/

有人可以帮忙吗?

【问题讨论】:

  • 那么根据 jsfiddle,您现在的基本需求是动画?
  • 沃尔克,没错。我只是不知道该怎么做。
  • CSS3 过渡/动画在这里无法满足您的需求,因为您必须支持 IE8。在我的理解中最关键的一点是沿着左上角的箭头。我想您必须选择一个带有完整箭头的图层(已经存在),然后在顶部的另一个图层上使用背景隐藏尚未动画的部分和正在改变位置的箭头。带有边界半径的拐角动画似乎相当耗时。
  • 好吧,我可以为最右上方的指针(即“箭头”类)保留流动画,但我仍然需要先为 vrt-bar 制作动画,然后再为顶部 hrzt-bar 制作动画。
  • 或者即使它需要更改html/css,也可以。

标签: jquery html css jquery-animate


【解决方案1】:

试试这个 我想以下任何一个都是你需要的

工作DEMO1

我稍微编辑了你的 CSS, 和代码

$('.arrow-up').animate({
    'top': '-5px'
}, 1000, function () {
    $(this).addClass('arrow').removeClass('arrow-up');
    $('.arrow').animate({
        'left': '177px'
    }, 1000);
});

另一种类型在这里

我稍微编辑了你的 CSS, 和代码

工作DEMO2

$(document).ready(function () {
    $('.arrow-up').animate({
        'top': '-10px'
    }, 1000, function () {
        $(this).addClass('arrow').removeClass('arrow-up');
        $('.arrow').animate({
            'left': '177px'
        }, 1000);
    });
    $('.vrt-bar').animate({'height':'192px'},1000,function(){
    $('.hrzt-bar').delay(80).animate({'width':'143px'},1000);
    });

});

【讨论】:

  • 好吧,我实际上是在寻找整个箭头,而不是箭头指针(即“箭头”类)从底部开始动画(即从“vrt-bar”类的底部开始直到顶部和然后从“hrzt-bar”类开始到结束,然后是“箭头”类)。但是 DEMO1 看起来也很有趣,确实如此,只是有一种方法可以为箭头指针设置动画,即从下到上然后从左到右的类“箭头”。在你的情况下,它只是从左到右移动。如果这行得通,我想我可能能够说服我的客户。感谢您对此提出不同的方向。
  • 哦,我才发现在你的DEMO1中,“箭头”类已经从下往上移动,然后从左到右,只是移动到顶部的速度非常快,因此它看起来如此。无论如何,我将检查该解决方案是否有效。再次感谢。
  • @whyAto8,我也更新了DEMO1,动画慢,看看这个
  • 很抱歉,OP 没有接受答案 +1 以获得好的答案,因为它应该被接受。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-23
  • 2020-09-07
  • 2016-06-18
  • 2020-10-23
  • 1970-01-01
相关资源
最近更新 更多