CSS3 Translate across an Arc

前端 未结 3 1281
囚心锁ツ
囚心锁ツ 2020-12-13 17:52

Is it at all possible with current CSS3 to translate an object (specifically a DIV) along an arc or curve? Here\'s an image to help illustrate.

3条回答
  •  庸人自扰
    2020-12-13 18:28

    Yes, that animation can be created using the transform-origin CSS3 property to set the rotation point in the far right so it moves like that.

    Check it out: http://jsfiddle.net/Q9nGn/4/ (put your mouse over)

    #c {
        border: 1px solid black;
        height: 400px;
    }
    
    #c:hover #m {
        -webkit-transform: rotate(180deg);
        -webkit-transition: all 1s ease-in-out;
        -moz-transform: rotate(180deg);
        -moz-transition: all 1s ease-in-out;
        -o-transform: rotate(180deg);
        -o-transition: all 1s ease-in-out;
        -ms-transform: rotate(180deg);
        -ms-transition: all 1s ease-in-out;
        transform: rotate(180deg);
        transition: all 1s ease-in-out;
    }
    
    #m {
        width: 60px;
        height: 60px;
        position: absolute;
        background: green;
        border-radius: 30px;
        top: 270px;
        left: 20px;
        -webkit-transform-origin:300px 30px;
        -moz-transform-origin:300px 30px;
        -o-transform-origin:300px 30px;
        -ms-transform-origin:300px 30px;
        transform-origin:300px 30px;
    }

提交回复
热议问题