最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

svg+css 或者js制作打鉤的動畫效果

  發(fā)布時間:2020-03-31 15:33:10   作者:Published   我要評論
這篇文章主要介紹了svg+css 或者js制作打鉤的動畫效果,本文通過實例代碼給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下

之前老板讓做一個登陸后 可以顯示一個打鉤的效果 百度死活搜不到 今天在B站看到的一個視頻居然有 根據(jù)需求改進了一下廢話不多說先看效果!

html代碼

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>打鉤動畫</title>
</head>
<body>
<div id="d1">
    <input type="checkbox" style="display: none" id="love1" />
    <label for="love1" id="btn1" >完成</label>
<svg width="200px" height="200px">
    <circle r="90" class="circle" fill="none" stroke="#2de540" stroke-width="10" cx="100" cy="100" stroke-linecap="round" transform="rotate(-90 100 100) " ></circle>
    <polyline  fill="none" stroke="#2de540" stroke-width="10" points="44,107 86,137 152,69" stroke-linecap="round" stroke-linejoin="round" class="tick" ></polyline>
</svg>
<h2 style="text-align: center;width: 200px">成功</h2>

</div>
</body>
<!--這里引入你本地的jq-->
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
</html>

css代碼

h2 {
        font-family: Helvetica;
        font-size: 30px;
        margin-top: 20px;
        color: #333;
        opacity: 0;
    }
    input[type="checkbox"]:checked+ label ~ h2 {
        animation: .6s title ease-in-out;
        animation-delay: 1.2s;
        animation-fill-mode: forwards;
    }
    .circle {
        stroke-dasharray: 1194;
        stroke-dashoffset: 1194;
    }
    input[type="checkbox"]:checked + label + svg .circle {
        animation: circle 1s ease-in-out;
        animation-fill-mode: forwards;
    }
    .tick {
        stroke-dasharray: 350;
        stroke-dashoffset: 350;
    }
    input[type="checkbox"]:checked + label+ svg .tick {
        animation: tick .8s ease-out;
        animation-fill-mode: forwards;
        animation-delay: .95s;
    }
    @keyframes circle {
        from {
            stroke-dashoffset: 1194;
        }
        to {
            stroke-dashoffset: 2388;
        }
    }
    @keyframes tick {
        from {
            stroke-dashoffset: 350;
        }
        to {
            stroke-dashoffset: 0;
        }
    }
    @keyframes title {
        from {
            opacity: 0;
        }
        to {
            opacity: 1;
        }
    }
    label {
        display: inline-block;
        height: 38px;
        width: 38px;
        line-height: 38px;
        padding: 0 18px;
        background-color: #1E9FFF;
        color: #fff;
        white-space: nowrap;
        text-align: center;
        font-size: 14px;
        border: none;
        border-radius: 2px;
        cursor: pointer;
    }
    #d1 {
        display: flex;
        justify-content: center;
        min-height: 100px;
        flex-direction: column;
    }

寫到這里本來應(yīng)該就結(jié)束了 但是我們在真正實現(xiàn)功能的時候 不太可能用 checkbox切換動畫效果的顯示 一般還是需要按鈕操作動畫效果 下面是jq操作的代碼 其實用jq的.animate()更好一些但是我是小白所以就偷了個懶 (ps:好吧其實是不會)直接用.css()

JavaScript代碼

  $("#btn1").on("click",function () {
       if($(this).text()==="完成"){
           $(".circle").css({'animation':'circle 1s ease-in-out','animation-fill-mode':'forwards'});
           $(".tick").css({'animation':'tick .8s ease-out','animation-fill-mode':'forwards','animation-delay':'.95s'});
           $("h2").css({'animation':'.6s title ease-in-out','animation-fill-mode':'forwards','animation-delay':'1.2s'})
           $(this).text("取消")
       }else{
           $(".circle").css({'animation':'none','animation-fill-mode':'none'});
           $(".tick").css({'animation':'none','animation-fill-mode':'none'});
           $("h2").css({'animation':'none','animation-fill-mode':'none'})
           $(this).text("完成")
       }
   });

到此這篇關(guān)于svg+css 或者js制作打鉤的動畫效果的文章就介紹到這了,更多相關(guān)svg css 打鉤動畫內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論

通州市| 台东市| 乐亭县| 普兰店市| 盐山县| 德钦县| 正阳县| 象山县| 新乡县| 高尔夫| 漾濞| 黔江区| 墨竹工卡县| 青海省| 沭阳县| 隆昌县| 内丘县| 广南县| 玉屏| 高邑县| 台江县| 白玉县| 白山市| 精河县| 樟树市| 柞水县| 岳阳市| 方山县| 五华县| 大邑县| 三原县| 阿克苏市| 武川县| 焦作市| 垦利县| 珲春市| 马鞍山市| 珠海市| 乳山市| 门源| 大厂|