HTML Menu Designer

The HTML menu designer lets you create menus with smooth fading and color blending effects. The menus are compatible with most browsers, because they are not based on flash.

The menus only need pure HTML, CSS and javascript which can be found in all modern browsers (tested with Firefox 2 + 3, Internet Explorer (IE 5, 5.5, 6), Konqueror and Opera) and it is even backward compatible with old browsers. With this designer you can change different parameters like background and foreground colors as well as border colors to define the overall look of the menu. Additionally, the javascript is so small that it loads extremely fast.

Colors and Layout

Standard Hovered


Menu entries

One menu entry per row.




The results

Preview


Resulting Markup and Code

Please copy this to an empty html-file. You can extract the javascript and css later and rename everything.

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--
Copyright (c) 2007 Ulrich Mierendorff
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
-->
    <title>Menu example</title>
<style type="text/css">
<!--

#mainmenu .inact,
#mainmenu .act {
    background-color: rgb(41,41,41);
    border: 1px solid rgb(41,41,41);
    width: 200px;
    padding: 5px;
    margin: 0px;
    margin-bottom: 0px;
    margin-left: 10px;
    
    display: block;
    color: rgb(140,140,140);
    text-decoration: none;
    font-family: arial, sans-serif;
}
-->
</style>
<script type="text/javascript">
<!--

var width1 = 200;       // width of link
var width2 = 220;
var bgcolor1 = [41,41,41]; // background-color
var bgcolor2 = [41,0,0];
var fgcolor1 = [140,140,140]; // foreground-color
var fgcolor2 = [255,255,255];
var bordercolor1 = [41,41,41]; // border-color
var bordercolor2 = [212,212,212];
var margin1 = 10;       // margin-left of link (used for centered resize)
var margin2 = 0;
var fadeintime = 300; // time to fade in if mouse hovers (milliseconds)
var fadeouttime = 300;// time to fade out
var fps = 30.0;         // frames per second (30.0 seems to be a good value)


/* Program code */
var buttons = new Array();
/*
0:  element "pointer"
1:  active? -> processing a fading (true/false)
2:  interval object
3:  current fading status (0...1)
4:  direction (-1/+1)
*/
var log = "";
function applyfading (i, time)
{
    buttons[i][3] += buttons[i][4]*(1000.0/fps) / time;
    if (buttons[i][3] < 0)
    {
        buttons[i][3] = 0;
        deactivatebutton (i);
    }
    else if (buttons[i][3] > 1)
    {
        buttons[i][3] = 1;
        deactivatebutton (i);
    }
    var x = buttons[i][3];
    
    buttons[i][0].style["backgroundColor"] = "rgb(" +
                    (Math.floor (bgcolor1[0]*(1-x) + bgcolor2[0]*x)) + "," +
                    (Math.floor (bgcolor1[1]*(1-x) + bgcolor2[1]*x)) + "," +
                    (Math.floor (bgcolor1[2]*(1-x) + bgcolor2[2]*x)) +")";
    buttons[i][0].style["color"] = "rgb(" +
                    (Math.floor (fgcolor1[0]*(1-x) + fgcolor2[0]*x)) + "," +
                    (Math.floor (fgcolor1[1]*(1-x) + fgcolor2[1]*x)) + "," +
                    (Math.floor (fgcolor1[2]*(1-x) + fgcolor2[2]*x)) +")";
    buttons[i][0].style["borderColor"] = "rgb(" +
                    (Math.floor (bordercolor1[0]*(1-x) + bordercolor2[0]*x)) + "," +
                    (Math.floor (bordercolor1[1]*(1-x) + bordercolor2[1]*x)) + "," +
                    (Math.floor (bordercolor1[2]*(1-x) + bordercolor2[2]*x)) +")";

    if (width1 != width2)
        buttons[i][0].style["width"] = (Math.floor(width1*(1-x) + width2*x)) + "px";
    if (margin1 != margin2)
        buttons[i][0].style["marginLeft"] = (Math.floor(margin1*(1-x) + margin2*x)) + "px";
}

function get_button (element)
{
    for (var i=0; i < buttons.length; i++)
    {
        if (buttons[i][0] == element)
            return i;
    }
    i = buttons.length;
    buttons[i] = new Array (element, false, 0, 0.0, 0);
    return i;
}

function deactivatebutton (i) {
    if (buttons[i][1])
    {
        buttons[i][1] = false;
        clearInterval (buttons[i][2]);
    }
}

function fade (element, direction, time)
{
    var i = get_button (element);
    deactivatebutton (i);
    buttons[i][1] = true;
    buttons[i][4] = direction;
    buttons[i][2] = window.setInterval ("applyfading("+i+","+time+")",1000.0/fps);
}


// called by user (a call could be "fadein (this)")
function fadein (element)
{
    fade (element, +1, fadeintime);
}

function fadeout (element)
{
    fade (element, -1, fadeouttime);
}

//-->
</script>
</head>
<body>
    <h1>Menus, Menus, Menus...</h1><div id="mainmenu">
<a href="" class="inact" onmouseover="javascript: fadein (this);" onmouseout="javascript: fadeout (this);">Small and Stable</a>
<a href="" class="inact" onmouseover="javascript: fadein (this);" onmouseout="javascript: fadeout (this);">Cross-Browsing</a>
<a href="" class="inact" onmouseover="javascript: fadein (this);" onmouseout="javascript: fadeout (this);">Backward compatible!</a>
<a href="" class="inact" onmouseover="javascript: fadein (this);" onmouseout="javascript: fadeout (this);">less than 100 lines of code</a>
</div></body>
</html>