css3實現手機菜單展開收合動畫

來源:互聯網
上載者:User

標籤:

<!DOCTYPE html><html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><title>Examples</title><meta name="description" content=""><meta name="keywords" content=""><link href="" rel="stylesheet"><script type="text/javascript" src="jquery.js"></script></head><style type="text/css">.test {margin: 500px auto;text-align: center;width: 100px;height: 100px;}.test button {height: 100px;background: none;outline: none;cursor: pointer;border: none;}.test span { width: 100px;height: 10px;background: red;position: relative;display: block;border-radius: 10px;transition: background .3s .2s ;/*啟用之後 ,前面的秒數是動畫消耗的時間,後面的秒數是延遲開始的時間*/}.test span:before {content: "";display: block;top: -30px;left: 0;width: 100px;height: 10px;background: red;position: absolute;border-radius: 10px;transition: top .3s .2s ease, -webkit-transform .3s ease;}.test span:after {content: "";background: red;display: block;width: 100px;height: 10px;top: 30px;position: absolute;left: 0;border-radius: 10px;transition: top .3s .2s ease, -webkit-transform .3s ease;}.test button.active span {background: transparent;border-radius: 10px;-webkit-transform-origin: 50% 50%;    transition:  background .2s .1s ease;    /*啟用之前 ,前面的秒數是動畫消耗的時間,後面的秒數是延遲開始的時間*/}.test button.active span:before {transform: rotate(45deg);top: 0;transition: top .3s ease, -webkit-transform .3s .2s ease;}.test button.active span:after {transform: rotate(-45deg);top: 0;transition: top .3s ease, -webkit-transform .3s .2s ease;}</style><body>    <div class="test">        <button>    <span></span>    </button>    </div></body></html><script type="text/javascript">    //自訂開關    var _a = true;    $("button").click(function(){    if(_a == true){            $(this).addClass("active");            _a= false;        }else{        $(this).removeClass("active");            _a= true;        }    })</script>

  

css3實現手機菜單展開收合動畫

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.