javascript - HTML website menu animation -
html:
<div id="menu" class="menu"> <ul class="headlines"> <li id="item1"onclick="checklist(this)"><button onclick="myfunction()">aa</button></li> <li id="item2"><button onclick="myfunction2()">a </button></li> <li id="item3">b </li> <li id="item4">c </li> <li id="item5">d </li> <li id="item6">e </li> <li id="item7">f </li> </ul> </div>
css:
lu, li{ list-style-type: none; font-size: 1.5em; height: 40px; width: 150px; text-align: right; border-style: none; } .menu{ width:150px; height: 350px; margin:0 auto; } .menu li{ position: relative; top:150px; bottom: 0; right: 0; margin: auto; border-style:none; }
i want animate menu centered in middle of website, go ultimate left in form / ,when clicking on 1 of elements. help?
here quick bit of jquery li clicked left;
$(".headlines li").click(function () { $(this).animate({left: '-300px'}, 600) })
edit
to move of them when clicking link create css below, below normal menu css,
.menuclicked{ position: relative; width:150px; height: 350px; left: -300px; transition: 1s; }
then use jquery;
$(".headlines li").click(function () { $(".menu").addclass("menuclicked"); })
edit 2 (adding delay)
to make them go 1 @ time .delay between animations stagger them.
$(".headlines li").click(function () { $("#item1").animate({left: '-300px'}, 600) $("#item2").delay(100).animate({left: '-300px'}, 600) $("#item3").delay(200).animate({left: '-300px'}, 600) $("#item4").delay(300).animate({left: '-300px'}, 600) $("#item5").delay(400).animate({left: '-300px'}, 600) $("#item6").delay(500).animate({left: '-300px'}, 600) $("#item7").delay(600).animate({left: '-300px'}, 600) })
Comments
Post a Comment