Howdy! I'm Jiby and I'm a web designer creates attractive, accessible standard compliant websites good at css, html

 
 

Sliding LavaLamp jQuery menu

Nov 02 2009

This post is an interesting tutorial for making sliding hover nifty effect of Lava Lamp menu which uses jQuery. The source of the post is from gmarwaha.

You can also find the mootools version of the same sliding hover nifty effect of Lava Lamp menu from Guillermo Rauch’s site.

1. The HTML code of the menu

In this the “ul” tag is the menu container and each “li” is menu-item.

<ul class="lavaLamp">
            <li><a href="#">Home</a></li>
            <li><a href="#">Plant a tree</a></li>
            <li><a href="#">Travel</a></li>
            <li><a href="#">Ride an elephant</a></li>
</ul>

2. The CSS code

The CSS used in example is as follows

/* Styles for the entire LavaLamp menu */
.lavaLamp {
    position: relative;
    height: 29px; width: 421px;
    background: url("../image/bg.gif") no-repeat top;
    padding: 15px; margin: 10px 0;
    overflow: hidden;
}
    /* Force the list to flow horizontally */
    .lavaLamp li {
        float: left;
        list-style: none;
    }
        /* Represents the background of the highlighted menu-item. */
        .lavaLamp li.back {
            background: url("../image/lava.gif") no-repeat right -30px;
            width: 9px; height: 30px;
            z-index: 8;
            position: absolute;
        }
            .lavaLamp li.back .left {
                background: url("../image/lava.gif") no-repeat top left;
                height: 30px;
                margin-right: 9px;
            }
        /* Styles for each menu-item. */
        .lavaLamp li a {
            position: relative; overflow: hidden;
            text-decoration: none;
            text-transform: uppercase;
            font: bold 14px arial;
            color: #fff; outline: none;
            text-align: center;
            height: 30px; top: 7px;
            z-index: 10; letter-spacing: 0;
            float: left; display: block;
            margin: auto 10px;
        }

3. JavaScript

Include the following code to the head section of HTML.

<script type="text/javascript" src="path/to/jquery.js"></script>
<script type="text/javascript" src="path/to/jquery.lavalamp.js"></script>
<!-- Optional -->
<script type="text/javascript" src="path/to/jquery.easing.js"></script>

<script type="text/javascript">
    $(function() { $(".lavaLamp").lavaLamp({ fx: "backout", speed: 700 })});
</script>

You can download the source file from gmarwaha. Please click here to get the latest version

Bookmark this..

http://www.jibysk.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png http://www.jibysk.com/wp-content/plugins/sociofluid/images/delicious_48.png http://www.jibysk.com/wp-content/plugins/sociofluid/images/newsvine_48.png http://www.jibysk.com/wp-content/plugins/sociofluid/images/technorati_48.png http://www.jibysk.com/wp-content/plugins/sociofluid/images/magnolia_48.png http://www.jibysk.com/wp-content/plugins/sociofluid/images/google_48.png http://www.jibysk.com/wp-content/plugins/sociofluid/images/myspace_48.png http://www.jibysk.com/wp-content/plugins/sociofluid/images/facebook_48.png http://www.jibysk.com/wp-content/plugins/sociofluid/images/yahoobuzz_48.png http://www.jibysk.com/wp-content/plugins/sociofluid/images/twitter_48.png http://www.jibysk.com/wp-content/plugins/sociofluid/images/meneame_48.png

Tags: | |

Leave a Reply