I have this navbar and it works fine on computer screen, because of :hover. But on mobile screen you have to click on navbar to open it. I want to hide navbar when li is selected. But I'm not sure how to do it :/ I have to make main-menu width 60px and overflow hidden. I made it with javasript but it works only once. If you want to open it again, the width and overwflow ofc stays the same.
.fa {
position: relative;
display: table-cell;
width: 60px;
height: 36px;
text-align: center;
vertical-align: middle;
font-size:20px;
}
.stick{
position: sticky;
top: 0;
bottom: 0;
}
.main-menu:hover,nav.main-menu.expanded {
width:250px;
overflow:visible;
}
li:hover + .main-menu:hover, nav.main-menu.expanded{
overflow: hidden !important;
width: 60px !important;
}
.main-menu {
background: grey;
border-right:1px solid #e5e5e5;
height:100%;
width:60px;
-webkit-transition:width .05s linear;
transition:width .05s linear;
-webkit-transform:translateZ(0) scale(1,1);
z-index:1000;
position: absolute;
}
.main-menu>ul {
margin:7px 0;
overflow: hidden;
}
.main-menu li {
position:relative;
display:block;
width:250px;
}
.main-menu li>a {
position:relative;
display:table;
border-collapse:collapse;
border-spacing:0;
color:#999;
font-family: arial;
font-size: 14px;
text-decoration:none;
-webkit-transform:translateZ(0) scale(1,1);
-webkit-transition:all .1s linear;
transition:all .1s linear;
}
.main-menu .nav-icon {
position:relative;
display:table-cell;
width:60px;
height:36px;
text-align:center;
vertical-align:middle;
font-size:18px;
}
.main-menu .nav-text {
position:relative;
display:table-cell;
vertical-align:middle;
width:190px;
}
.no-touch .scrollable.hover {
overflow-y:hidden;
}
.no-touch .scrollable.hover:hover {
overflow-y:auto;
overflow:visible;
}
a:hover,a:focus {
text-decoration:none;
}
nav {
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
-o-user-select:none;
user-select:none;
}
nav ul,nav li {
outline:0;
margin:0;
padding:0;
}
.main-menu li:hover>a,nav.main-menu li.active>a,.dropdown-menu>li>a:hover,.dropdown-menu>li>a:focus,.dropdown-menu>.active>a,.dropdown-menu>.active>a:hover,.dropdown-menu>.active>a:focus,.no-touch .dashboard-page nav.dashboard-menu ul li:hover a,.dashboard-page nav.dashboard-menu ul li.active a {
color:black;
background-color:#5fa2db;
}
.area {
height: 100%;
}
#font-face {
font-family: 'Titillium Web';
font-style: normal;
font-weight: 300;
src: local('Titillium WebLight'), local('TitilliumWeb-Light'), url(http://themes.googleusercontent.com/static/fonts/titilliumweb/v2/anMUvcNT0H1YN4FII8wpr24bNCNEoFTpS2BTjF6FB5E.woff) format('woff');
}
.container{
margin: 0 !important;
}
<nav class="main-menu">
<ul class="stick">
<li>
<a href="#1">
<i class="fa fa-home fa-2x"></i>
<span class="nav-text">
aa
</span>
</a>
</li>
<li class="has-subnav">
<a href="#">
<i class="fa fa-laptop fa-2x"></i>
<span class="nav-text">
bb
</span>
</a>
</li>
<li class="has-subnav">
<a href="#">
<i class="fa fa-list fa-2x"></i>
<span class="nav-text">
cc
</span>
</a>
</li>
<li class="has-subnav">
<a href="#">
<i class="fa fa-folder-open fa-2x"></i>
<span class="nav-text">
dd
</span>
</a>
</li>
<li>
<a href="#">
<i class="fa fa-bar-chart-o fa-2x"></i>
<span class="nav-text">
ee
</span>
</a>
</li>
</ul>
</nav>
document.getElementsByTagName("body")[0].onclick = function(event){
if(event.target.offsetParent.offsetParent.tagName == "LI"){
document.getElementsByClassName("main-menu")[0].style.width = "60px";
}
}
document.getElementsByClassName("main-menu")[0].onmouseover = function(event){
this.style.width = "250px";
this.style.overflow = "visible";
}
Related
//#384a5a clear color
//#2f3f4d dark color
when I hover and click the arrow right: content: "\e080"; get light color : #384a5a,
the background should be the same as the li background: #2f3f4d.
everything it is wroking perfect just this background colour when I hover the li with arrow right: content: "\e080"; get different background.
So what I try to archive is: make the bg colour the same as the li when I hover the arrow right.
jsfiddle: http://jsfiddle.net/Wc4xt/4393/
html:
<div class="sidebar ">
<div class="sidebar-wrapper">
<ul class="sidebar-nav">
<li>test
</li>
<li>
test
</li>
<li>
<i class="pull-left fa-lg fa fa-barcode" aria-hidden="true"></i>
test
</li>
<li>
<div class="collapse-link">
<a data-toggle="collapse" data-target="#collapseExample1" aria-expanded="true" aria-controls="collapseExample1" class="">tes
</a>
</div>
<div class="collapse-styled collapse in" id="collapseExample1" aria-expanded="true">
test
<a class="current" href="test">test</a>
test
</div>
</li>
<li>
<i class="pull-left fa fa-lg fa-book" aria-hidden="true"></i>
<div class="collapse-link">
<a data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample" class="collapsed">test
</a>
</div>
<div class="collapse-styled collapse" id="collapseExample" aria-expanded="false" style="height: 0px;">
test
test
test
</div>
</li>
<li>
<i class="pull-left fa fa-map" aria-hidden="true"></i>
<a href="test">test
</a>
</li>
</ul>
</div>
</div>
css:
.sidebar-wrapper {
height: 100%;
overflow-y: auto;
background: #384a5a;
-webkit-transition: all 0.5s ease;
transition: all 0.5s ease;
}
.sidebar-nav {
font-size: 0.8125em;
}
.sidebar-nav i {
margin-top: 20px;
margin-left: 25px;
color: #3181cc;
}
.sidebar-nav li {
line-height: 60px;
border-bottom: 1px solid #455b6f;
}
.sidebar-nav li:nth-child(1) {
color: #3181cc;
background-color: #273440;
font-size: 1.5em;
height: 65px;
text-indent: 20px;
}
.sidebar-nav li.current {
background: #000;
}
.sidebar-nav li.current a {
color: #ffffff;
border-right: 5px solid #000;
}
.sidebar-nav li a:hover {
text-decoration: none;
color: #ffffff;
border-right: 5px solid #3181cc;
background: #2f3f4d;
}
.sidebar-nav li a {
display: block;
height: 65px;
}
.collapse-link a {
background-color: #2f3f4d;
border-right: 5px solid #3181cc;
}
.collapse-link a:after {
font-family: 'Glyphicons Halflings';
content: "\e114";
float: right;
color: #ffffff;
margin-right: 20px;
background-color: #2f3f4d;
}
.collapse-link a.collapsed {
background-color: #384a5a;
border-right: 5px solid #384a5a !important;
}
.collapse-link a.collapsed:after {
font-family: 'Glyphicons Halflings';
content: "\e080";
background-color: #384a5a !important;
}
.collapse-link a.collapsed:after:hover {
background: #2f3f4d;
}
Working fiddle fiddle
add this css.
.collapse-link a.collapsed:after {
font-family: 'Glyphicons Halflings';
content: "\e080";
background-color: #2f3f4d !important;
}
.sidebar-nav li a:hover:after {
font-family: 'Glyphicons Halflings';
content: "\e080";
background-color: #2f3f4d !important;
}
please use this style sheet
.collapse-link a.collapsed::after {
background-color: rgba(0, 0, 0, 0);
}
I want to have a headline on the left side and buttons on the right side. Between I want a line.
.container {
background-image: url(http://www.deutsches-museum.de/fileadmin/Content/010_DM/020_Ausstellungen/100_Museumsinsel/030_Turm/030_Kunst/bild32.jpg);
height: 100px;
color: #fff;
}
.col-xs-8 {
border: 1px solid blue;
}
ul {
display: flex;
text-align: justify;
margin: 0;
padding: 0;
list-style-type: none;
}
ul li {
overflow: hidden;
white-space: nowrap;
}
li:first-child {
padding-right: 10px;
}
li:last-child {
padding-left: 10px;
font-size: 10px;
}
h2 {
margin: 10px 0 0 0;
font-size: 20px;
font-weight: normal;
}
.fa-stack-1x {
color: #777;
}
.line {
margin: 0 auto 5px;
border-bottom: 2px solid red;
width: 100%;
}
<div class="container">
<div class="row">
<div class="col-xs-8">
<div class="breadcrump">
<ul class="menu">
<li>
<h2>Here is a example Headline</h2>
</li>
<li class="line"></li>
<li>
<span class="fa-stack fa-lg">
<i class="fa fa-square fa-stack-2x"></i>
<i class="fa fa fa-chevron-left fa-stack-1x"></i>
</span>
<span class="fa-stack fa-lg">
<i class="fa fa-square fa-stack-2x"></i>
<i class="fa fa fa-chevron-right fa-stack-1x"></i>
</span>
</li>
</ul>
</div>
</div>
</div>
</div>
With justify the line overlays the Headline and the buttons and this is not what I want.
http://codepen.io/daluela/pen/aOVmGw
If I understand what you want, all you need to do is replace width:100% in .line with flex:1;.
Remove overflow:hidden from your list items.
http://codepen.io/anon/pen/gpXgRW
ul li {
overflow: hidden;/*remove this*/
white-space: nowrap;
}
Unabridged Explanation
Last night I was working on replicating an interesting Codepen I found. After I finished it, I was extremely happy with how it worked. Since I wasn't planning on using it in production, I neglected to use the proper CSS prefixes to insure cross-browser compatibility. However, when I decided to check it in Safari and Firefox I noticed that my ":hover" events weren't translating properly, and so far I have been unable to fix it. I do not need this project for anything, but I would like some help figuring out why this is occurring so I can be prepared to address this issue in future developments.
Direct Problem
In Firefox and Safari, when you mouse over the menu items that are to the right of the "Fly-Out" menu headers they collapse, whereas in Chrome they remain out.
I would like to stress that I understand why certain features like the transitions aren't working, as I didn't specify the "webkit" or "moz" prefix for most of them. It is simply the collapsing menu that's troubling me.
Code
ul.sidebar {
display: block;
position: absolute;
margin: 0;
left: 0;
height: 100%;
width: 6.5em;
background: #aa2266;
padding: 0;
text-align: center;
}
ul.sidebar * {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
ul.sidebar a {
color: white;
text-decoration: none;
margin: 0;
display: inline-block;
width: 100%;
height: 100%;
}
ul.sidebar a > i {
margin-top: 0.13333em;
font-size: 2em;
display: block;
margin-bottom: 0.2em;
}
ul.sidebar a > span {
font-size: 0.8em;
font-family: sans-serif;
}
ul.sidebar li {
transition: background 0.3s;
background: #aa2266;
}
ul.sidebar > li {
margin: 0;
padding: 0;
height: 4em;
display: inline-block;
position: relative;
width: 100%;
background: #aa2266;
transition: background 0.3s;
}
ul.sidebar > li:hover {
background: #dc3278;
}
ul.sidebar > li:hover:after {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 100%;
width: 6px;
background: linear-gradient(to right, rgba(0, 0, 0, 0.25) 0%, transparent 100%);
}
ul.sidebar > li > a {
transition: background 0.3s;
}
ul.sidebar > li > a:hover {
background: #ff5f87;
}
ul.sidebar > li > ul {
overflow: hidden;
height: 4em;
padding: 0;
position: absolute;
z-index: -1;
margin: 0;
color: red;
left: 100%;
transition-delay: 0.3s;
transition-property: transform;
transition-duration: 0.6s;
-webkit-transform: translateX(-100%);
transform: translateX(-100%);
width: auto;
list-style: none;
white-space: nowrap;
top: 0;
background: #dc3278;
}
ul.sidebar > li > ul > li {
overflow: hidden;
background: none;
margin: 0 0px 0 -4px;
padding: 0;
display: inline-block;
width: 6.5em;
height: 4em;
transition: background 0.3s;
}
ul.sidebar > li > ul > li:hover {
background: #fa648c;
}
ul.sidebar li:hover > ul {
-webkit-transform: translateX(0);
transform: translateX(0);
}
ul.sidebar li:hover > ul > li {
color: white;
}
body {
padding: 0;
position: fixed;
margin: 0;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: #450f30;
}
description {
position: absolute;
bottom: 0;
right: 0;
padding: 0 0.4em 1em 0;
color: white;
font-size: 20px;
font-family: times new roman;
}
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<description>
Full Stack Developer
</description>
<ul class="sidebar">
<li>
<a href="#">
<i class="fa fa-home"></i>
<span>
My Projects
</span>
</a>
<ul>
<li>
<a>
<i class="fa fa-question-circle"></i>
<span>Nothing</span>
</a>
</li>
<li>
<a>
<i class="fa fa-square"></i>
<span>Boxes for all</span>
</a>
</li>
<li>
<a>
<i class="fa fa-th-large"></i>
<span>More boxes</span>
</a>
</li>
</ul>
</li>
<li>
<a>
<i class="fa fa-info-circle"></i>
<span>
About
</span>
</a>
<ul>
<li>
<a>
<i class="fa fa-eye"></i>
<span>I have eyes</span>
</a>
</li>
<li>
<a>
<i class="fa fa-bed"></i>
<span>and a bed</span>
</a>
</li>
<li>
<a>
<i class="fa fa-heartbeat"></i>
<span>plus cool icons</span>
</a>
</li>
</ul>
</li>
<li>
<a>
<i class="fa fa-globe">
</i>
<span>
Links
</span>
</a>
<ul>
<li>
<a>
<i class="fa fa-external-link"></i>
<span>No Links</span>
</a>
</li>
<li>
<a>
<i class="fa fa-fire"></i>
<span>For the wicked</span>
</a>
</li>
</ul>
</li>
<li>
<a>
<i class="fa fa-envelope-o"></i>
<span>
Contact
</span>
</a>
<ul>
<li>
<a href="mailto:alec.menke#gmail.com">
<i class="fa fa-user"></i>
<span style="font-size: 8px;">alec.menke#gmail.com</span>
</a>
</li>
</ul>
</li>
</ul>
Code Pen
The problem wasn't the vendor prefixes for transforms and transition. The problem was z-index: -1 property. By definition, element with absolute position should be on top of all the elements positioned inline or relative. The trick with -1 worked and placed it below the parent menu element which has position relative. However, in Firefox and IE it was placed even below the body, so when the mouse hovers on dropped menu in fact in hovers on body, i.e. out of the parent menu <li> element.
To solve this problem I made the changes:
In the ul.sidebar > li > a class changed z-index to 1, and added the following properties to the ul.sidebar > li > a class:
position: absolute;
left: 0;
background: #aa2266;
z-index: 1;
I've checked the result on Firefox and Internet Explorer and now it works fine :)
ul.sidebar {
display: block;
position: absolute;
margin: 0;
left: 0;
height: 100%;
width: 6.5em;
background: #aa2266;
padding: 0;
text-align: center;
}
ul.sidebar * {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
ul.sidebar a {
color: white;
text-decoration: none;
margin: 0;
display: inline-block;
width: 100%;
height: 100%;
}
ul.sidebar a > i {
margin-top: 0.13333em;
font-size: 2em;
display: block;
margin-bottom: 0.2em;
}
ul.sidebar a > span {
font-size: 0.8em;
font-family: sans-serif;
}
ul.sidebar li {
transition: background 0.3s;
background: #aa2266;
}
ul.sidebar > li {
margin: 0;
padding: 0;
height: 4em;
display: inline-block;
position: relative;
width: 100%;
background: #aa2266;
transition: background 0.3s;
}
ul.sidebar > li:hover {
background: #dc3278;
}
ul.sidebar > li:hover:after {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 100%;
width: 6px;
background: linear-gradient(to right, rgba(0, 0, 0, 0.25) 0%, transparent 100%);
}
ul.sidebar > li > a {
position: absolute;
left: 0;
background: #aa2266;
z-index: 1;
transition: background 0.3s;
}
ul.sidebar > li > a:hover {
background: #ff5f87;
}
ul.sidebar > li > ul {
overflow: hidden;
height: 4em;
padding: 0;
position: absolute;
z-index: 0;
margin: 0;
color: red;
left: 100%;
transition-delay: 0.3s;
transition-property: transform;
transition-duration: 0.6s;
-webkit-transform: translateX(-100%);
transform: translateX(-100%);
width: auto;
list-style: none;
white-space: nowrap;
top: 0;
background: #dc3278;
}
ul.sidebar > li > ul > li {
overflow: hidden;
background: none;
margin: 0 0px 0 -4px;
padding: 0;
display: inline-block;
width: 6.5em;
height: 4em;
transition: background 0.3s;
}
ul.sidebar > li > ul > li:hover {
background: #fa648c;
}
ul.sidebar li:hover > ul {
-webkit-transform: translateX(0);
transform: translateX(0);
}
ul.sidebar li:hover > ul > li {
color: white;
}
body {
padding: 0;
position: fixed;
margin: 0;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: #450f30;
}
description {
position: absolute;
bottom: 0;
right: 0;
padding: 0 0.4em 1em 0;
color: white;
font-size: 20px;
font-family: times new roman;
}
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<description>
Full Stack Developer
</description>
<ul class="sidebar">
<li>
<a href="#">
<i class="fa fa-home"></i>
<span>
My Projects
</span>
</a>
<ul>
<li>
<a>
<i class="fa fa-question-circle"></i>
<span>Nothing</span>
</a>
</li>
<li>
<a>
<i class="fa fa-square"></i>
<span>Boxes for all</span>
</a>
</li>
<li>
<a>
<i class="fa fa-th-large"></i>
<span>More boxes</span>
</a>
</li>
</ul>
</li>
<li>
<a>
<i class="fa fa-info-circle"></i>
<span>
About
</span>
</a>
<ul>
<li>
<a>
<i class="fa fa-eye"></i>
<span>I have eyes</span>
</a>
</li>
<li>
<a>
<i class="fa fa-bed"></i>
<span>and a bed</span>
</a>
</li>
<li>
<a>
<i class="fa fa-heartbeat"></i>
<span>plus cool icons</span>
</a>
</li>
</ul>
</li>
<li>
<a>
<i class="fa fa-globe">
</i>
<span>
Links
</span>
</a>
<ul>
<li>
<a>
<i class="fa fa-external-link"></i>
<span>No Links</span>
</a>
</li>
<li>
<a>
<i class="fa fa-fire"></i>
<span>For the wicked</span>
</a>
</li>
</ul>
</li>
<li>
<a>
<i class="fa fa-envelope-o"></i>
<span>
Contact
</span>
</a>
<ul>
<li>
<a href="mailto:alec.menke#gmail.com">
<i class="fa fa-user"></i>
<span style="font-size: 8px;">alec.menke#gmail.com</span>
</a>
</li>
</ul>
</li>
</ul>
Hello I have CSS dropdown menu, when I hover with the mouse to the firt item the submenu shows correctly but when I try to go down for example to the last item of the submenu before I get there the submenu gets closed... I can't find what I'm doing wrong Below is my code:
CSS:
#lang_select ul{
padding: 0px;
margin: 0;
border: solid 1px #e1e1e1;
width: 85px;
}
#lang_select li{
display: inline;
position: relative;
}
#lang_select ul ul{
position: absolute;
display: none;
}
#lang_select li:hover ul{
display: block;
}
#lang_select a{
text-decoration: none;
color:#333;
font-family: Open Sans;
font-size:12px;
}
.lang-down{
padding-left:10px;
}
HTML:
<div id="lang_select">
<ul>
<li>
Language <i class="fa fa-angle-down"></i>
<ul>
<li><span class="lang-down"><i class="fa fa-globe"></i> Albanian</span></li>
<li><span class="lang-down"><i class="fa fa-globe"></i> French</span></li>
<li><span class="lang-down"><i class="fa fa-globe"></i> German</span></li>
</ul>
</li>
</ul>
</div>
demo - http://jsfiddle.net/r0bdcn7y/1/
change the css
#lang_select li {
display: inline-block;
position: relative;
width: 100%;
}
#lang_select ul {
padding: 0px;
margin: 0;
border: solid 1px #e1e1e1;
width: 85px;
}
#lang_select li {
display: inline-block;
position: relative;
width: 100%;
}
#lang_select ul ul {
position: absolute;
display: none;
}
#lang_select li:hover ul {
display: block;
}
#lang_select a {
text-decoration: none;
color: #333;
font-family: Open Sans;
font-size: 12px;
}
.lang-down {
padding-left: 10px;
}
<div id="lang_select">
<ul>
<li> Language <i class="fa fa-angle-down"></i>
<ul>
<li><span class="lang-down"><i class="fa fa-globe"></i> Albanian</span>
</li>
<li><span class="lang-down"><i class="fa fa-globe"></i> French</span>
</li>
<li><span class="lang-down"><i class="fa fa-globe"></i> German</span>
</li>
</ul>
</li>
</ul>
</div>
I want to change the color of the "Green" backline while hovering the menu items. The color will be changed according to the hovered menu item; i.e. when hovering on the first item, the backline color will be that "Bluish". How can I get this effect? Here is my JSFiddle: http://jsfiddle.net/n86UN/embedded/result/
Also, How can I set the 'span' elements(hovered effect) always right under the respective color blocks if I change the width or height of the blocks. As you see I have changed the width & height of the blocks from 120px to 150px. And the span elements are appearing haphazardly.
Thank U in advance...
Here is my code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Flat Nav</title>
<style type="text/css" media="screen">
nav{
position: relative;
text-align: center;
}
nav:after {
content: "";
width: 100%;
height: 2px;
background-color: green;
position: absolute;
right: 0;
top: 50%; /* 50% from the top */
z-index: -1;
}
nav ul {
display: inline-block; list-style: none; position: relative;
}
nav ul li {
float: left; margin: 0 20px 0 0;
}
nav ul li a {
display: block; width: 150px; height: 150px; opacity: 0.9;
}
nav ul li:nth-child(1) a {
background-color: #5bb2fc;
}
nav ul li:nth-child(2) a {
background-color: #58ebd3;
}
nav ul li:nth-child(3) a {
background-color: #ffa659;
}
nav ul li:nth-child(4) a {
background-color: #ff7a85;
}
nav ul li a span {
font: 20px "Dosis", sans-serif; text-transform: uppercase;
display: none;
}
nav ul li a:hover span {
display: block;
}
nav ul li:nth-child(1) a span {
color: #5bb2fc;
position: absolute; left: 70px; top: 160px;
}
nav ul li:nth-child(2) a span {
color: #58ebd3;
position: absolute; left: 200px; top: 160px;
}
nav ul li:nth-child(3) a span {
color: #ffa659;
position: absolute; left: 320px; top: 160px;
}
nav ul li:nth-child(4) a span {
color: #ff7a85;
position: absolute; left: 470px; top: 160px;
}
</style>
</head>
<body>
<div id="demo">
<nav>
<ul>
<li>
<a href="#">
<span>Home</span>
</a>
</li>
<li>
<a href="#">
<span>About</span>
</a>
</li>
<li>
<a href="#">
<span>Portfolio</span>
</a>
</li>
<li>
<a href="#">
<span>Contact</span>
</a>
</li>
</ul>
</nav>
</div>
</body>
</html>
A working example on JSFiddle. It works in Chrome 32.0.1700.68 beta and Safari 7.0.1. I don't know if this works in any other browsers.
<body>
<div id="demo">
<nav>
<ul>
<li>
<a class="nav nav-blue" href="#">
<span class="label-wrapper">
<span class="label">Home</span>
</span>
<span class="nav-after"></span>
</a>
</li>
<li>
<a class="nav nav-green" href="#">
<span class="label-wrapper">
<span class="label">About</span>
</span>
<span class="nav-after"></span>
</a>
</li>
<li>
<a class="nav nav-yellow" href="#">
<span class="label-wrapper">
<span class="label ">Portfolio</span>
</span>
<span class="nav-after"></span>
</a>
</li>
<li> <a class="nav nav-red" href="#">
<span class="label-wrapper">
<span class="label">Contact</span>
</span>
<span class="nav-after"></span>
</a>
</li>
</ul>
</nav>
</div>
</body>
CSS:
nav {
position: relative;
text-align: center;
}
nav:after, .nav-after {
content:"";
width: 100%;
height: 2px;
position: absolute;
right: 0;
top: 50%;
/* 50% from the top */
}
nav:after {
background-color: green;
z-index: 1;
}
nav ul {
display: inline-block;
list-style: none;
}
nav ul li {
float: left;
margin: 0 20px 0 0;
}
.nav {
z-index:100;
width: 150px;
height: 150px;
display:block;
}
.label-wrapper {
position:relative;
width: 150px;
height: 150px;
opacity: 0.9;
display:block;
z-index:100;
}
.label {
position: absolute;
top: 160px;
left: 10px;
font: 20px"Dosis", sans-serif;
text-transform: uppercase;
display: none;
}
.nav:hover .label {
display: block;
}
.nav:hover .nav-after {
display:block;
z-index: 10;
}
/* Colors */
.nav-blue .label-wrapper, .nav-blue:hover .nav-after {
background-color: #5bb2fc;
}
.nav-blue .label {
color: #5bb2fc;
}
.nav-green .label-wrapper, .nav-green:hover .nav-after {
background-color: #58ebd3;
}
.nav-green .label {
color: #58ebd3;
}
.nav-yellow .label-wrapper, .nav-yellow:hover .nav-after {
background-color: #ffa659;
}
.nav-yellow .label {
color: #ffa659;
}
.nav-red .label-wrapper, .nav-red:hover .nav-after {
background-color: #ff7a85;
}
.nav-red .label {
color: #ff7a85;
}