Inspiration for Line Menu Styles

Some ideas for menu styles and effects that employ the line as a creative design element. This is an open collection; contributions are welcome!

LineMenuStyles

View demo Download source

The line is an amazing design element. It’s so versatile and it allows us to use it for adding enjoyable animations or enhance points of interest. Today we’d like to share a set of ideas for using the line as a design element in horizontal menus. There are many creative possibilities, some minuscule and subtle, others bold and more extravagant. We’ve prepared a little inspirational set for you where we explore some line menu styles.

We’d also like to invite you to contribute your style to this open collection. Check out the details on GitHub.

menustyle

Let’s have a look at the markup which is, aside from some exceptions, the same for every menu style:


<section class="section section--menu" id="Prospero">

	<h2 class="section__title">Prospero</h2>

	<nav class="menu menu--prospero">

		<ul class="menu__list">
			<li class="menu__item menu__item--current">
				<a class="menu__link">Home</a>
			</li>
			<li class="menu__item">
				<a class="menu__link">Who we are</a>
			</li>
			<li class="menu__item">
				<a class="menu__link">What we offer</a>
			</li>
			<li class="menu__item">
				<a class="menu__link">Our news</a>
			</li>
			<li class="menu__item">
				<a class="menu__link">Contact us</a>
			</li>
		</ul>
		
	</nav>

</section>

The menu__item--current class indicates the currently selected item. Note that we use a BEM naming convention but allow for the main nav to have an indicative class that we then use in our stylesheet (component.css) to define the individual styles.

Let’s have a look at the common styles for all menus:

.menu {
	line-height: 1;
	margin: 0 auto 3em;
}

.menu__list {
	position: relative;
	display: -webkit-flex;
	display: flex;
	-webkit-flex-wrap: wrap;
	flex-wrap: wrap;
	margin: 0;
	padding: 0;
	list-style: none;
}

.menu__item {
	display: block;
	margin: 1em 0;
}

.menu__link {
	font-size: 1.05em;
	font-weight: bold;
	display: block;
	padding: 1em;
	cursor: pointer;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
	-webkit-touch-callout: none;
	-khtml-user-select: none;
	-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.menu__link:hover,
.menu__link:focus {
	outline: none;
}

We’ll use flexbox for the menu layout and define some common styles for the links.

The following is an effect style example (vendor prefixed properties omitted):

/* Prospero */

.menu--prospero .menu__link {
	position: relative;
	display: block;
	margin: 0 1.5em;
	padding: 0.75em 0;
	text-align: center;
	color: #b5b5b5;
	transition: color 0.3s;
}

.menu--prospero .menu__link:hover,
.menu--prospero .menu__link:focus {
	color: #929292;
}

.menu--prospero .menu__item--current .menu__link {
	color: #d94f5c;
}

.menu--prospero .menu__link::before {
	content: '';
	position: absolute;
	left: 0;
	bottom: 0;
	width: 100%;
	height: 4px;
	background: #d94f5c;
	transform: scale3d(0, 1, 1);
	transition: transform 0.1s;
}

.menu--prospero .menu__item--current .menu__link::before {
	transform: scale3d(1, 1, 1);
	transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
	transition-duration: 0.3s;
}

In this effect we simply use a pseudo element line that starts to expand from the middle. It is positioned absolutely at the bottom of the link and initially scaled to 0 on the X. When we select a menu item by clicking on it, the line gets scaled to 1.

We hope you enjoy this little set and find it inspirational!

Don’t forget to fork the repo and add your styles if you like. Read more about it on the GitHub project page:

View demo Download source

Previous:
Next:

Tagged with:

ML is a freelance web designer and developer with a passion for interaction design. She studied Cognitive Science and Computational Logic and has a weakness for the smell of freshly ground peppercorns.

View all contributions by

Website: http://www.codrops.com

Related Articles

CSS Reference

Learn about all important CSS properties from the basics with our extensive and easy-to-read CSS Reference.

It doesn't matter if you are a beginner or intermediate, start learning CSS now.

Feedback 47

  1. 4

    Great idea opening in up to the crowd, I think you’ll get some great results from the talented people that follow your awesome blog.

  2. 7

    Wow! This is a great tutorial, I was searching for exactly the same thing on how to create this kind of menus. Thank you for this tutorial & your clean code markup!

  3. 8

    For a single page application (or single page website) I see this working in a sticky menu or something. But when you have hard links to other pages, the animation won’t run (won’t have time to since the page is redirecting).

    How would one tackle this problem? Build in a javascript timer on the menu links that delays the click to the new page so the a.menu__item–current can be reassigned or something?
    Feels incredibly nasty.., ideas?

  4. 9

    Menus can often be the most boring aspect of any website. The style presented here helps to revitalise the menu and make it interactive and interesting in its own right. There are many good ways of doing this.

  5. 10

    Hello, i’m a beginner and i don’t really understand how associate correctly a link working correctly with this menu

    the base on the demo works fine with the effect :
    Illustration

    And now if i add a link to test in local :
    Illustration

    the link to redirect on the other page illustration.html doesn’t work, nothing happens….

    I suspect the part of the js script, like i said i’m a beginner and i truly don”t understant all js parts on this demo.

    Someone could help to resolve this simple things : how could i add links to other pages on this kind of menu, i will appreciate for sure if someone save me ^^

    ty, friendly
    Stéphane

    ps: sorry for my english…

  6. 12

    with the quote is better :
    the base on the demo works fine with the effect :
    <li class="indigo-text menu__item menu__item--current"><a href="#" class="menu__link">Illustration</a>
    </li>

    And now if i add a link to test in local :
    <li class="indigo-text menu__item menu__item--current"><a href="illustration.html" class="menu__link">Illustration</a>
    </li>

  7. 14

    Hello, really nice menu. You would like to have your permission to create a wordpress plugin implementing this functionality.

    • 15

      Hi. I would to know what the exact ways to create this line menu styles in wordpress? I am stuck and unsuccessful to include this awesome plugin.

      Please assist.

  8. 16

    As always this website is a unique source of great design and frontend development inspiration.

    Thanks!

  9. 18

    Anybody see that working? It doesn’t redirect to the page when define address in hyperlink tag eg. <li class="menu__item"><a href="index.php" class="menu__link">About</a></li>

  10. 20

    use autoscrolling jquery code , and put same page hyperlink, to auto scroll to some part of the page , it doesn’t work on some external link.

  11. 22

    Is there any way I can automatically assign the class to the nav item where my page is currently up to?

    I want the styling to change automatically if the user scrolls and not only if the user clicks on the nav link?

  12. 23

    Hi,

    The link href”#” in : <a href=”#” rel=”nofollow”>HOME</a>
    is no working . . Any idea ?

    Thanks you.

    • 24

      Gabyto, I tried “Valentine” and any href didn’t worked because the javascript main function has a event prevent default (that prevents the “click” to do the default action, if you remove that line, Valentine doesn’t work at all… so I changed the whole javascript, I stoped using “classie.js” and any other library related to the example (but jquery) and did my own javascript… (that is only 6 lines…) and now it works.

    • 25

      Just delete the part of the ‘link copy’ in the javascript code

Follow this discussion

Leave a Comment