Drawing animated arc with pure CSS

后端 未结 6 1770
挽巷
挽巷 2020-12-30 06:22

I know it is possible to draw and animate arcs in svg and canvas. However, is it possible in css?

I have created an arc using the following method:

.         


        
6条回答
  •  鱼传尺愫
    2020-12-30 06:37

    I may be a little late, but I think using two "hiders" and translating one up and one down will look a little better.

    Working Example

    body { background:orange; } .wrap { position:absolute; height:400px; width:170px; overflow: hidden; } .arc { position:absolute; width:150px; height:400px; margin:10px; border-radius:50%; border-right:1px solid black; border-left:1px solid black; border-top:1px solid black; border-bottom:1px solid transparent; } .arc:before { content:""; position:absolute; left:-1px; top:-2px; background: orange; width:76px; height:375px; animation:unhide1 5s linear both; } .arc:after { content:""; position:absolute; left:75px; top:-2px; background: orange; float: right; width:76px; height:375px; animation: unhide2 5s linear 5s both; } @keyframes unhide1 { 100% { transform: translatey(-375px); } } @keyframes unhide2 { 100% { transform: translatey(375px); } }

提交回复
热议问题