Demo
  • 2.45 KB
  • HTML, CSS, JS
  • Menu
  • dropdown, sliding, vertical
  • MIT License
HTML
<nav class="vert-nav" role="navigation">
    <ul class="topmenu">
        <li><a href="#0">Home</a></li>
        <li>
            <a href="#0">About</a>
            <ul class="submenu">
                <li><a href="#0">Our Story</a></li>
                <li><a href="#0">The Team</a></li>
                <li><a href="#0">Core Values</a></li>
            </ul>
        </li>
        <li>
            <a href="#0">Projects</a>
            <ul class="submenu">
                <li><a href="#0">Wordpress</a></li>
                <li><a href="#0">Case Studies</a></li>
                <li><a href="#0">Products</a></li>
            </ul>
        </li>
        <li><a href="#0">Contact Us</a></li>
    </ul>
</nav>
CSS
.vert-nav a {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
.vert-nav a {
    color: #3d9970;
    text-decoration: none;
    margin-bottom: 1em;
}
.vert-nav a:hover {
    color: #ff851b;
}
.vert-nav {
    width: 33%;
}

.vert-nav ul {
    list-style: none;
    padding: 0;
}
.vert-nav .topmenu li.openmenu > a {
    background: #50a37e;
}
.vert-nav .topmenu li.openmenu .sf {
    -webkit-transform: rotate(180deg);
}
.vert-nav .topmenu li {
    position: relative;
}
.vert-nav .topmenu li .sf {
    position: absolute;
    z-index: 9;
    top: 1em;
    right: 1em;
    color: #378a65;
    -moz-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    -webkit-transition: all 0.3s ease;
    transition: all 0.3s ease;
    -webkit-backface-visibility: hidden;
}
.vert-nav .topmenu li:last-child a {
    border-bottom: 0.2em solid #398e68;
}
.vert-nav .topmenu li a {
    margin: 0;
    padding: 1em;
    display: block;
    width: 100%;
    background: #3d9970;
    color: #fff;
    border-bottom: 0.1em solid #398e68;
}
.vert-nav .topmenu li a:hover {
    background: #50a37e;
}
.vert-nav .submenu {
    display: none;
}
.vert-nav .submenu li:last-child a {
    border-width: 0.1em;
}
.vert-nav .submenu li a {
    padding-left: 2.6em;
    background: #3b946d;
    -moz-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    -webkit-transition: all 0.3s ease;
    transition: all 0.3s ease;
}
.vert-nav .submenu li a:hover {
    background: #3c976f;
}
JS
$(".vert-nav .topmenu a").click(function () {
    var $menu = $(this).next(".submenu");
    $menu.slideToggle("slow");
    $menu.parent().toggleClass("openmenu");
});

The code snippet we’re looking at brings to life a stylish navigation element on a webpage, often referred to as a vertical menu. This vertical menu is designed to neatly organize links for easy access, and it does so with a modern twist: it includes dropdown menus for subcategories. Picture a neat column on a webpage where each menu item not only takes you to different sections but some of them can expand, revealing more options. This is especially handy for websites with lots of pages or categories, making navigation a breeze.

Diving into the CSS part, it’s like the wardrobe of our menu, deciding how it looks and feels. The styles make sure the menu and its dropdown siblings aren’t just functional but also pleasing to the eye. Colors, padding, and transitions are meticulously defined to ensure everything from the main menu items to the dropdown links are visually cohesive and react smoothly when interacted with. Imagine hovering over a menu item and it changes color – that’s CSS magic at work, enhancing user experience with visual feedback.

The structure is pretty clever too. It uses a combination of <nav> and <ul> elements to create a hierarchy – main menu items and their dropdown (submenu) items, all neatly organized in a vertical lineup. This sliding menu effect, where submenus appear with a smooth animation, isn’t just for show; it helps users navigate through options without overwhelming them with too much information at once. It’s a blend of aesthetics and functionality, ensuring the website remains user-friendly and stylish.

  •  Menu #144
    Menu #23
    Menu #23
    • HTML, CSS, JS
    • 9.83 KB
    • Vertical
    View Details
  •  Menu #145
    Menu #22
    Menu #22
    • HTML, CSS
    • 5.96 KB
    • Dropdown, Vertical
    View Details
  •  Menu #145
    Menu #21
    Menu #21
    • HTML, CSS
    • 1.62 KB
    • Sidebar, Sliding, Vertical
    View Details
  •  Menu #144
    Menu #20
    Menu #20
    • HTML, CSS
    • 4.94 KB
    • Sliding, Vertical
    View Details
  •  Menu #144
    Menu #19
    Menu #19
    • HTML, CSS
    • 8.15 KB
    • Hamburger, Sliding, Vertical
    View Details
  •  Menu #144.5
    Menu #18
    Menu #18
    • HTML, CSS
    • 2.87 KB
    • Vertical
    View Details
Menu