Change Congress

Xark 2.0

  • Xark is a group blog with primary authors in Charleston, SC, and Nashville, Tenn. It dates back to June 2005. A sister blog,xarkGirl, launched here in October 2008.

Xark media


  • ALIENS! SEX! MORE ALIENS! AND DUBYA, TOO! Handcrafted, xarky science fiction, lovingly typeset for your home printer!

  • XARK TV

  • XARKAGANDA

  • XARKTOONS

Blog Local

Dan's G-Reader

Indigo Journal's Blogroll

Xark Essentials

Statcounter has my back

Blog powered by TypePad
Member since 06/2005

« re: My cabinet post | Main | The case for Armageddon »

Tuesday, November 18, 2008

Style for a dropdown menu

This is too geeky for words, but the stylesheet works.

<title>HTML Advanced - Horizontal Dropdown Menu</title>
    <link rel="stylesheet" href="basestyles.css" type="text/css">
    <link rel="stylesheet" href="cssmenus.css" type="text/css">

    <style type="text/css">

        /* *********This page's style goes here */
        /* this is a two-level menu that can be horizontal or vertical.
        This menu is set up as a horizontal dropdown menu */

        .twoLevelMenu a {/*  set styles for all anchors in the menu */
            display:block;
            border:1px solid black;
            padding:2px 0px 2px 5px;
            margin:2px 2px 0px 0px;
            color:#ffffff;
            text-decoration:none;
            font-family: sans-serif;
            font-size:12px;
            text-align:center;
            background-color: #577;
        }

        .twoLevelMenu ul {/* set style for all lists in the menu */
            list-style:none;/* removes the bullets */
            padding:0px;/* removes the indents on all the lists */
            margin:0px;/* removes the indents on all the lists */
            font-weight: bold;
            /* if a VERTICAL MENU, uncomment the following width and set to the same value as the next rule */
            /*width: 120px;*/
            width:auto;
        }

        .twoLevelMenu li {/* style all list items */
            width:120px;
            float:left;/* this turns the list items into a horizontal menu */
            position:static;/* set up parent positioning so its child position will work */

        }    

        .twoLevelMenu li ul {/* adjust the position and width of the second-level menus */
            width:100px;/* this width is the same as the rule above */
            background-image:url(images/shim.gif); /* this is a transparent one-pixel .gif that tiles automatically and keeps the submenus from collapsing in IE when there is space between the submenu items*/
            /* if a VERTICAL MENU, use the next two settings instead */
            /*margin-top:-24px;*/ /* moves the submenu up next to the associated list item */
            /*margin-left:110px;*/ /* set to the menu width or less to overlap the flyout menus */
            position:absolute;/* allows the submenus to be hidden before the hover*/
            display:none;/* hide the submenus */
        }

        .twoLevelMenu li:hover ul { /* this is the trick that brings the submenus back */
            display:block;
        }

        .twoLevelMenu li:hover a { /* style top item menus style hovers */
            background-color:#979;
        }

        .twoLevelMenu li:hover li a { /* style unhovered submenu list items */
            background-color:#966;
        }

        .twoLevelMenu li li:hover a {
            background-color: #979;
        }

                /* ************************************** */
        </style>    

        <!-- The following is an Internet Explorer conditional comment.
        It applies styles that only IE versions less than the version 7 will understand.
        Put styles here to work around earlier versions' lack of CSS compliance.
        All other browsers will ignore the conditional comment.
         -->

        <!--[if lt IE 7]>
            <style type="text/css">
                body {
                    behavior:url(csshover2.htc); /* Makes IE play nice with all hovered elements*/
                }
            </style>    
        <![endif]-->

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d8341c5d3453ef010535f9eda0970b

Listed below are links to weblogs that reference Style for a dropdown menu:

Comments

Neat stuff. Have you seen this site?

http://css.maxdesign.com.au/listamatic/

Helpful. Also, since you seem interested in CSS, take a look at:

http://www.blueprintcss.org/

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment