DZone
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
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Coding
  3. Languages
  4. MS Office-Style CSS3 Multilevel Menu

MS Office-Style CSS3 Multilevel Menu

Andrey Prikaznov user avatar by
Andrey Prikaznov
·
May. 07, 12 · Interview
Like (0)
Save
Tweet
Share
7.58K Views

Join the DZone community and get the full member experience.

Join For Free

in our new tutorial i will give you another brilliant crossbrowser css3 navigation menu. this is a click action drop down menu with strict office styles (like ms office styles). you can also use different icons in this menu. this solution is ideal for business websites. if you are ready, let's start.


this is our final result:

office style css3 multilevel menu

here are the samples and downloadable package:

live demo

download in package


ok, download the sources and let's start coding !


step 1. html

pleasedirect  your attention to the html layout of our multilevel menu. this is the usual ul-li based multilevel navigation menu. of course, the most interesting thing is the css styles.

index.html

<div id="nav">
    <ul>
        <li><span tabindex="1">file</span>
            <ul>
                <li><a href="#"><img src="images/icon1.gif" alt="" />new</a></li>
                <li><a href="#"><img src="images/icon2.gif" alt="" />open</a></li>
                <li><a href="#"><img src="images/icon3.gif" alt="" />close</a></li>
                <li><span tabindex="1"><img src="images/icon4.gif" alt="" />save</span>
                    <ul>
                        <li><span tabindex="1"><img src="images/icon4.gif" alt="" />option 1</span>
                            <ul>
                                <li><a href="#"><img src="images/icon1.gif" alt="" />option a</a></li>
                                <li><a href="#"><img src="images/icon2.gif" alt="" />option b</a></li>
                                <li><a href="#"><img src="images/icon3.gif" alt="" />option c</a></li>
                            </ul>
                        </li>
                        <li><a href="#"><img src="images/icon2.gif" alt="" />option 2</a></li>
                        <li><a href="#"><img src="images/icon3.gif" alt="" />option 3</a></li>
                    </ul>
                </li>
                <li><a href="#"><img src="images/icon5.gif" alt="" />save as</a></li>
                <li><a href="#"><img src="images/icon1.gif" alt="" />print</a></li>
                <li><a href="#"><img src="images/icon2.gif" alt="" />exit</a></li>
            </ul>
        </li>
        <li><span tabindex="1">edit</span>
            <ul>
                <li><a href="#"><img src="images/icon1.gif" alt="" />cut</a></li>
                <li><a href="#"><img src="images/icon2.gif" alt="" />copy</a></li>
                <li><a href="#"><img src="images/icon3.gif" alt="" />paste</a></li>
            </ul>
        </li>
        <li><span tabindex="1">view</span>
            <ul>
                <li><a href="#"><img src="images/icon1.gif" alt="" />normal</a></li>
                <li><a href="#"><img src="images/icon2.gif" alt="" />web layout</a></li>
                <li><a href="#"><img src="images/icon3.gif" alt="" />print layout</a></li>
            </ul>
        </li>
        <li><a href="#">insert</a></li>
        <li><a href="#">format</a></li>
        <li><a href="#">tools</a></li>
        <li><a href="#">table</a></li>
        <li><a href="#">window</a></li>
        <li><a href="http://www.script-tutorials.com/">help</a></li>
        <img class="close" src="images/spacer.gif" alt="" />
    </ul>
</div>

step 2. css

here are the css styles of our click action dropdown menu.

css/menu.css

#nav {
    position:relative;
    z-index:2;
}
#nav ul {
    background-color:#b8d1f8;
    border:1px solid #000c80;
    height:24px;
    list-style:none outside none;
    margin:0;
    padding:1px;
}
#nav ul ul {
    background-color:#ffffff;
    border:1px solid #8a867a;
    display:none;
    height:auto;
    left:0;
    padding:0;
    position:absolute;
    top:25px;
    width:168px;

    background-image:-webkit-gradient(left center , #f8faff 0%, #b8d1f8 15%, #ffffff 15%, #ffffff 100%);
    background-image:-moz-linear-gradient(left center , #f8faff 0%, #b8d1f8 15%, #ffffff 15%, #ffffff 100%);
}
#nav ul ul ul {
    display:none;
    left:168px;
    position:absolute;
    top:-1px;
    width:168px;
}
#nav ul li {
    float:left;
    margin-right:1px;
    position:relative;
}
#nav ul li a {
    border:1px solid #b8d1f8;
    color:#000;
    cursor:default;
    display:block;
    font:11px tahoma,arial;
    padding:3px 3px 4px;
    text-decoration:none;
}
#nav ul li span {
    background:url("../images/u.gif") no-repeat scroll 90% center transparent;
    border:1px solid #b8d1f8;
    color:#000;
    cursor:default;
    display:block;
    font:11px tahoma,arial;
    padding:3px 14px 4px 3px;
    position:relative;
}
#nav ul ul li span {
    background:url("../images/s.gif") no-repeat scroll 97% center transparent;
}
#nav ul ul li {
    float:none;
    margin-right:0;
    padding:1px;
    text-indent:10px;
}
#nav ul ul li a,#nav ul ul li span {
    border:1px solid transparent;
    padding:3px 3px 5px 2px;
}
#nav ul ul li a img,#nav ul ul li span img {
    border-width:0;
    float:left;
    margin-right:5px;
    vertical-align:middle;
}
#nav ul li:hover > a,#nav ul li:hover > span {
    background-color:#fff2c8;
    border:1px solid #000c80;
    color:#000;
}
#nav img.close {
    display:none;
    height:100%;
    left:0;
    position:fixed;
    top:0;
    width:100%;
    z-index:-1;
}
#nav ul li span:focus + ul,#nav ul li ul:hover,#nav ul:hover + img.close {
    display:block;
}

less than 100 lines of code. it’s great, isn’t it?


live demo

download in package


conclusion

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

CSS

Published at DZone with permission of Andrey Prikaznov, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Multi-Cloud Integration
  • Microservices 101: Transactional Outbox and Inbox
  • How To Build a Spring Boot GraalVM Image
  • Getting a Private SSL Certificate Free of Cost

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • 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: