DZone
Web Dev Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Web Dev Zone > Creating a Multilevel CSS3 Metal Navigation with icons

Creating a Multilevel CSS3 Metal Navigation with icons

Andrey Prikaznov user avatar by
Andrey Prikaznov
·
Sep. 30, 11 · Web Dev Zone · Interview
Like (0)
Save
Tweet
4.77K Views

Join the DZone community and get the full member experience.

Join For Free

in our new tutorial we’ll create a beautiful css3 menu with icons in metal style. this is a pretty standard ul-li multilevel menu.


here are final result (what we will creating):

css3 menu11

here are samples and downloadable package:

live demo
download in package

ok, download the example files and lets start coding !


step 1. html

as usual, we start with the html. here are full html code of our menu. as you can see – this is multilevel menu. whole menu built on ul-li elements.

index.html

<!doctype html>
<html lang="en" >
    <head>
        <meta charset="utf-8" />
        <title>css3 metal menu with icons | script tutorials</title>

        <link rel="stylesheet" href="css/layout.css" type="text/css" media="screen">
        <link rel="stylesheet" href="css/menu.css" type="text/css" media="screen">
    </head>
    <body>
        <div class="container">

            <ul id="nav">
                <li><a href="#"><img src="images/home.png" /> home</a></li>
                <li><a href="#"><span><img src="images/top1.png" /> html/css</span></a>
                    <div class="subs">
                        <div class="col">
                            <ul>
                                <li><a href="#"><img src="images/bub.png" /> link 1</a></li>
                                <li><a href="#"><img src="images/bub.png" /> link 2</a></li>
                                <li><a href="#"><img src="images/bub.png" /> link 3</a></li>
                                <li><a href="#"><img src="images/bub.png" /> link 4</a></li>
                                <li><a href="#"><span><img src="images/top3.png" /> sublinks</span></a>
                                    <div class="subs">
                                        <div class="col">
                                            <ul>
                                                <li><a href="#"><img src="images/bub.png" /> link 41</a></li>
                                                <li><a href="#"><img src="images/bub.png" /> link 42</a></li>
                                                <li><a href="#"><img src="images/bub.png" /> link 43</a></li>
                                                <li><a href="#"><img src="images/bub.png" /> link 44</a></li>
                                                <li><a href="#"><img src="images/bub.png" /> link 45</a></li>
                                            </ul>
                                        </div>
                                        <div class="col">
                                            <ul>
                                                <li><a href="#"><img src="images/bub.png" /> link 46</a></li>
                                                <li><a href="#"><img src="images/bub.png" /> link 47</a></li>
                                                <li><a href="#"><img src="images/bub.png" /> link 48</a></li>
                                                <li><a href="#"><img src="images/bub.png" /> link 49</a></li>
                                            </ul>
                                        </div>
                                    </div>
                                </li>
                            </ul>
                        </div>
                        <div class="col">
                            <ul>
                                <li><a href="#"><img src="images/bub.png" /> link 6</a></li>
                                <li><a href="#"><img src="images/bub.png" /> link 7</a></li>
                                <li><a href="#"><img src="images/bub.png" /> link 8</a></li>
                                <li><a href="#"><img src="images/bub.png" /> link 9</a></li>
                                <li><a href="#"><img src="images/bub.png" /> link 10</a></li>
                            </ul>
                        </div>
                    </div>
                </li>
                <li><a href="#"><span><img src="images/top2.png" /> jquery/js</span></a>
                    <div class="subs">
                        <div class="col">
                            <ul>
                                <li><a href="#"><img src="images/bub.png" /> link 1</a></li>
                                <li><a href="#"><img src="images/bub.png" /> link 2</a></li>
                                <li><a href="#"><img src="images/bub.png" /> link 3</a></li>
                                <li><a href="#"><img src="images/bub.png" /> link 4</a></li>
                                <li><a href="#"><img src="images/bub.png" /> link 5</a></li>
                            </ul>
                        </div>
                        <div class="col">
                            <ul>
                                <li><a href="#"><img src="images/bub.png" /> link 6</a></li>
                                <li><a href="#"><img src="images/bub.png" /> link 7</a></li>
                                <li><a href="#"><img src="images/bub.png" /> link 8</a></li>
                                <li><a href="#"><img src="images/bub.png" /> link 9</a></li>
                                <li><a href="#"><img src="images/bub.png" /> link 10</a></li>
                            </ul>
                        </div>
                    </div>
                </li>
                <li><a href="#"><img src="images/top3.png" /> php</a></li>
                <li><a href="#"><img src="images/top4.png" /> mysql</a></li>
                <li><a href="#"><img src="images/top5.png" /> xslt</a></li>
            </ul>

        </div>

        <footer>
            <h2>css3 metal menu with icons</h2>
            <a href="http://www.script-tutorials.com/css3-metal-menu-with-icons" class="stuts">back to original tutorial on <span>script tutorials</span></a>
        </footer>
    </body>
</html>

step 2. css

here are the css styles of our menu. maybe you’ve noticed – that in our html – i have two css files: layout.css and menu.css. the first file (layout.css) contain the styles of our test page. we will not publish these styles in this article, but if you wish – you can find these styles in the package.

css/menu.css

ul#nav {
    display:block;
    float:left;
    font-family:trebuchet ms,sans-serif;
    font-size:0;
    padding:5px 5px 5px 0;

    background: -moz-linear-gradient(#f5f5f5, #c4c4c4); /* ff 3.6+ */
    background: -ms-linear-gradient(#f5f5f5, #c4c4c4); /* ie10 */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #f5f5f5), color-stop(100%, #c4c4c4)); /* safari 4+, chrome 2+ */
    background: -webkit-linear-gradient(#f5f5f5, #c4c4c4); /* safari 5.1+, chrome 10+ */
    background: -o-linear-gradient(#f5f5f5, #c4c4c4); /* opera 11.10 */
    filter: progid:dximagetransform.microsoft.gradient(startcolorstr='#f5f5f5', endcolorstr='#c4c4c4'); /* ie6 & ie7 */
    -ms-filter: "progid:dximagetransform.microsoft.gradient(startcolorstr='#f5f5f5', endcolorstr='#c4c4c4')"; /* ie8+ */
    background: linear-gradient(#f5f5f5, #c4c4c4); /* the standard */
}
ul#nav,ul#nav ul {
    list-style:none;
    margin:0;
}
ul#nav,ul#nav .subs {
    background-color:#444;
    border:1px solid #454545;

    border-radius:9px;
    -moz-border-radius:9px;
    -webkit-border-radius:9px;
}
ul#nav .subs {
    background-color:#fff;
    border:2px solid #222;
    display:none;
    float:left;
    left:0;
    padding:0 6px 6px;
    position:absolute;
    top:100%;
    width:300px;

    border-radius:7px;
    -moz-border-radius:7px;
    -webkit-border-radius:7px;
}
ul#nav li:hover>* {
    display:block;
}
ul#nav li:hover {
    position:relative;
}
ul#nav ul .subs {
    left:100%;
    position:absolute;
    top:0;
}
ul#nav ul {
    padding:0 5px 5px;
}
ul#nav .col {
    float:left;
    width:50%;
}
ul#nav li {
    display:block;
    float:left;
    font-size:0;
    white-space:nowrap;
}
ul#nav>li,ul#nav li {
    margin:0 0 0 5px;
}
ul#nav ul>li {
    margin:5px 0 0;
}
ul#nav a:active,ul#nav a:focus {
    outline-style:none;
}
ul#nav a {
    border-style:none;
    border-width:0;
    color:#181818;
    cursor:pointer;
    display:block;
    font-size:13px;
    font-weight:bold;
    padding:8px 18px;
    text-align:left;
    text-decoration:none;
    text-shadow:#fff 0 1px 1px;
    vertical-align:middle;
}
ul#nav ul li {
    float:none;
    margin:6px 0 0;
}
ul#nav ul a {
    background-color:#fff;
    border-color:#efefef;
    border-style:solid;
    border-width:0 0 1px;
    color:#000;
    font-size:11px;
    padding:4px;
    text-align:left;
    text-decoration:none;
    text-shadow:#fff 0 0 0;

    border-radius:0;
    -moz-border-radius:0;
    -webkit-border-radius:0;
}
ul#nav li:hover>a {
    border-style:none;
    color:#fff;
    font-size:13px;
    font-weight:bold;
    text-decoration:none;
    text-shadow:#181818 0 1px 1px;
}
ul#nav img {
    border:none;
    margin-right:8px;
    vertical-align:middle;
}
ul#nav span {
    background-position:right center;
    background-repeat:no-repeat;
    display:block;
    overflow:visible;
    padding-right:0;
}
ul#nav ul span {
    background-image:url("../images/arrow.png");
    padding-right:20px;
}
ul#nav ul li:hover>a {
    border-color:#444;
    border-style:solid;
    color:#444;
    font-size:11px;
    text-decoration:none;
    text-shadow:#fff 0 0 0;
}
ul#nav > li >a {
    background-color:transpa;
    height:25px;
    line-height:25px;

    border-radius:11px;
    -moz-border-radius:11px;
    -webkit-border-radius:11px;
}
ul#nav > li:hover > a {
    background-color:#313638;
    line-height:25px;
}
live demo
download in package

conclusion

hope you enjoyed with new menu, don’t forget to tell thanks and leave a comment :) good luck!

from http://www.script-tutorials.com/css3-metal-menu-with-icons/

CSS

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • An Overview of Key Components of a Data Pipeline
  • Implementing RBAC Configuration for Kubernetes Applications
  • The Engineer’s Guide to Creating a Technical Debt Proposal
  • Why Performance Projects Fail

Comments

Web Dev Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo