11 Ocak 2012 Çarşamba

Blogger / blog için jQuery ve CSS3 kullanma Yüzer HTML Menü ekle

Add a Floating HTML Menu Using jQuery and CSS3 To Blogger/blog


N
ormally if we have a web page with long content web browser displays scroll bars to navigate to the content which is not displayed initially. Then if we scroll down, bottom content will be displayed and all the navigation menu bars and content on the top will not be displayed. But Once an element is Floating to the web page no matter how long we scroll, it will stay in the same position as before. Lets add this menu to blogger/blog

View Demo


How To Add Floating HTML Menu To Blogger

Step : - 1

Login to your Blogger dashboard and navigate to Layout > Edit HTML and check the box of expand widget templates. Now search for the code ]]></b:skin>  once you find it, replace the code with the below code 
#navi {
    height: 50px;
    margin-top: 50px;
}

#menu {
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #426d9c), color-stop(40%, #0f67a1), color-stop(100%, #1384d1));
    background: -moz-linear-gradient(top, #426d9c, #0f67a1, #1384d1);
    
    border-radius: 5px;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    
    line-height: 50px;
    text-align: center;
    margin: 0 auto;
    padding: 0;
}



#navi ul {
    padding: 0;
}

#navi ul li {
    list-style-type: none;
    display: inline;
    margin-right: 15px;
}

#navi ul li a {
    color: #fff;
    text-decoration: none;
    text-shadow: 1px 1px 1px #000;
    padding: 3px 7px;
    
    border-radius: 5px;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    
    -webkit-transition-property: color, background;
    -webkit-transition-duration: 0.5s, 0.5s;
}

#navi ul li a:hover {
    background: #01458e;
    color: #ff0;

    -webkit-transition-property: color, background;
    -webkit-transition-duration: 0.5s, 0.5s;
}

.default {
    width: 850px;
    height: 50px;
    
    box-shadow: 0 5px 20px #888;
    -webkit-box-shadow: 0 5px 20px #888;
    -moz-box-shadow: 0 5px 20px #888;
}

.fixed {
    position: fixed;
    top: -5px;
    left: 0;
    width: 100%;
    
    box-shadow: 0 0 40px #222;
    -webkit-box-shadow: 0 0 40px #222;
    -moz-box-shadow: 0 0 40px #222;
}

 Step : - 2

find  </head> (using Ctrl+f )  
copy n paste below code just above/before</head>tag.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
    
    var menu = $('#menu'),
        pos = menu.offset();
        
        $(window).scroll(function(){
            if($(this).scrollTop() > pos.top+menu.height() && menu.hasClass('default')){
                menu.fadeOut('fast', function(){
                    $(this).removeClass('default').addClass('fixed').fadeIn('fast');
                });
            } 
            else if($(this).scrollTop() <= pos.top && menu.hasClass('fixed')){
                menu.fadeOut('fast', function(){
                    $(this).removeClass('fixed').addClass('default').fadeIn('fast');
                });
            }
        });

});
</script>

Step : - 3

Now add the HTML code for floating menu, to do That search for the code <body>
and paste below code after <body>.

<div id="navi">
    <div id="menu" class="default">
        <ul>

            <li><a href="#">Home</a></li>
            <li><a href="#">CSS</a></li>
            <li><a href="#">Design</a></li>
            <li><a href="#">Development</a></li>
            <li><a href="#">Freebies</a></li>
            <li><a href="#">Inspiration</a></li>

            <li><a href="#">Resources</a></li>            
            <li><a href="#">Tutorials</a></li>            
            <li><a href="#">WordPress</a></li>            
        </ul>
    </div><!-- close menu -->
</div><!-- close navi -->

Now Save the template and you are done.!!!
If You Enjoyed This Post Please Take 5 Seconds To Share It.

Hiç yorum yok:

Yorum Gönder