خرید بک لینک

Vote count: 0

I m trying to create in jquery top menu, with height depending on window scroll position. When I use $(selector).css("height", "value"); everything is ok but when I try do this by animate it does not work correct. Here is my code. Thanks for your help.

<!DOCTYPE   html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<style>
</style>
<body>
    <nav style="background-color:red; height:100px;" class="navbar-fixed-top navbar navbar-default my-navbar">
    </nav>
    <div style="width:100%; height:2000px; background-color:blue;" class="content"> 
    </div>

    <script>
        $(document).ready(function(){
            $(window).scroll(function(){
                var top=$(window).scrollTop();
                if(top>10){
                    $(".my-navbar").animate({height: '50px'}, "slow");
                }else{
                    $(".my-navbar").animate({height: '100px'}, "slow");
                }
            })
        })
    </script>
</body>
</html>

asked 3 mins ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 11 فروردين 1395 ساعت: 15:35

صفحه بندی