I've made a three level menu in HTML and CSS.
The menu works until the third level (under products). The third ul sub-menu isn't displaying properly. It's being aligned improperly. I want it to get out of it's parent menu and be positioned at the right.
Here is a jsfiddle with my code.
I've changed some postions of ul, li but they don't seem to be working for me.
CSS, HTML in the fiddle:
#nav,#nav ul {
list-style: none outside none;
margin: 0;
padding: 0;
}
#menucon {
width:100%;
background-color:#222;
}
#nav {
clear: both;
font-size: 12px;
height: 42px;
}
#nav ul {
background-color: #222;
background-color: rgba(34,34,34,0.70);
border:1px solid #222;
border-radius: 0 5px 5px 5px;
border-width: 0 1px 1px;
box-shadow: 0 5px 5px rgba(0, 0, 0, 0.5);
left: -9999px;
overflow: hidden;
position: absolute;
top: -9999px;
-moz-transform: scaleY(0);
-ms-transform: scaleY(0);
-o-transform: scaleY(0);
-webkit-transform: scaleY(0);
transform: scaleY(0);
}
#nav ul.sec { z-index: 2; }
#nav ul.third { z-index: 3; border:2px solid red; }
#nav li {
background: url('menu_line.png') no-repeat scroll right 5px transparent;
float: left;
position: relative;
}
#nav li a {
color: #FFFFFF;
display: block;
float: left;
font-weight: normal;
height: 27px;
padding: 14px 30px 0;
position: relative;
text-decoration: none;
text-shadow: 1px 1px 1px #000000;
}
#nav ul.subs li a {
color: #FFFFFF;
display: block;
float: left;
font-weight: normal;
height: 27px;
padding: 13px 25px 0;
position: relative;
width:178px;
text-decoration: none;
text-shadow: 1px 1px 1px #000000;
}
#nav li:hover > a {
color: #00B4FF;
}
#nav li:hover, #nav a:focus, #nav a:hover, #nav a:active {
background: none repeat scroll 0 0 #121212;
outline: 0 none;
}
#nav li:hover ul.subs.sec {
left: 0;
top: 41px;
-moz-transform: scaleY(1);
-ms-transform: scaleY(1);
-o-transform: scaleY(1);
-webkit-transform: scaleY(1);
transform: scaleY(1);
position:absolute;
}
#nav li:hover ul.subs.third {
left: 60px; /* test */
top: 41px;
-moz-transform: scaleY(1);
-ms-transform: scaleY(1);
-o-transform: scaleY(1);
-webkit-transform: scaleY(1);
transform: scaleY(1);
position:absolute;
}
#nav ul li {
background: none;
width: 100%;
}
#nav ul li.sec {position:relative;}
#nav ul li a {
float: none;
}
#nav ul li:hover > a {
background-color: #121212;
color: #00B4FF;
}
#lavalamp {
background: url('lavalamp.png') no-repeat scroll 0 0 transparent;
height: 16px;
left: 32px;
position: absolute;
top: 0px;
width: 64px;
-moz-transition: all 400ms ease-out ;
-ms-transition: all 400ms ease-out ;
-o-transition: all 400ms ease-out ;
-webkit-transition: all 400ms ease-out ;
transition: all 400ms ease-out ;
}
#lavalamp:hover {
-moz-transition-duration: 4500s;
-ms-transition-duration: 4500s;
-o-transition-duration: 4500s;
-webkit-transition-duration: 4500s;
transition-duration: 4500s;
}
#nav li:nth-of-type(1):hover ~ #lavalamp, #lavalamp.act1 {
left: 35px;
}
#nav li:nth-of-type(2):hover ~ #lavalamp, #lavalamp.act2 {
left: 180px;
}
#nav li:nth-of-type(3):hover ~ #lavalamp, #lavalamp.act3{
left: 345px;
}
#nav li:nth-of-type(4):hover ~ #lavalamp, #lavalamp.act4 {
left: 486px;
}
#nav li:nth-of-type(5):hover ~ #lavalamp, #lavalamp.act5 {
left: 620px;
}
<div id="menucon">
<ul class="innercon" id="nav">
<li>HOME PAGE</li>
<li>PRODUCTS
<ul class="subs sec">
<li class="sec">LEVEL 1
<ul class="subs third">
<li>LEVEL 2</li>
<li>LEVEL 2</li>
</ul>
</li>
<li>LEVEL 1</li>
<li>LEVEL 1</li>
<li>LEVEL 1</li>
<li>LEVEL 1</li>
<li>LEVEL 1</li>
</ul>
</li>
<li>CONTACT US</li>
<div id="lavalamp"></div>
</ul>
</div>
Here is a DEMO to try if it fits your problem.
You gonna have to add this just this css:
.third{
display: none;
}
li > ul.sec > li:hover > ul.third {
display: inline-block;
position: absolute;
left: 100%!important;
top: 0!important;
z-index: 9;
width: 150px;
}
Explanation:
when you hover your second level item (li) you will show your submenu 100% left, i.e. next to the hovered li and top: 0 will place it inline with the hovered li.
You can adjust the width and z-index for your needs.
is this what you wanted?
Your question is still kinda unclear what you want.
ul.sec {
overflow: visible !important;
}
.subs .third {
left: 228px !important;
top: 41px !important;
}
https://jsfiddle.net/gsw4jxy8/4/
Related
im trying to replicate the "Page" Dropdown Animation with the icon, but im having difficulties, someone know how to make it similar to the "Page scroll one"?
Im leaving the code, you can find the Button than im trying to replicate with the icon dropdown and where i am at the moment.
Here is the HTML CODE:
<!-- Google Font -->
<link href="https://fonts.googleapis.com/css2?family=Play:wght#400;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Josefin+Sans:wght#300;400;500;600;700&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
<header class="header">
<div class="container">
<div class="row">
<div class="col-lg-2">
<div class="header__logo">
<img src="img/logo.png" alt="">
</div>
</div>
<div class="col-lg-10">
<div class="header__nav__option">
<nav class="header__nav__menu mobile-menu">
<ul>
<li>Pages
<ul class="dropdown">
<li>About</li>
<li>Portfolio</li>
<li>Blog</li>
<li>Blog Details</li>
</ul>
</li>
</ul>
</nav>
<div class="header__nav__settings">
<ul>
<a href="#"><i class="fa fa-gear"></i>
<ul class="dropdown">
<li>Portfolio</li>
<li>Blog</li>
<li>Blog Details</li>
</ul>
</a>
</ul>
</div>
</div>
</div>
</div>
<div id="mobile-menu-wrap"></div>
</div>
</header>
Here is the css
.header {
position: absolute;
left: 0;
top: 0;
width: 100%;
background: transparent;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
z-index: 9;
}
.header__nav__menu {
display: inline-block;
margin-right: 45px;
}
.header__nav__menu ul li {
list-style: none;
display: inline-block;
margin-right: 45px;
position: relative;
}
.header__nav__menu ul li.active a:after {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
.header__nav__menu ul li:hover a:after {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
.header__nav__menu ul li:hover .dropdown {
top: 34px;
opacity: 1;
visibility: visible;
}
.header__nav__menu ul li:last-child {
margin-right: 0;
}
.header__nav__menu ul li .dropdown {
position: absolute;
left: 0;
top: 60px;
width: 140px;
background: black;
text-align: left;
padding: 2px 0;
z-index: 9;
opacity: 0;
visibility: hidden;
-webkit-transition: all, 0.3s;
-o-transition: all, 0.3s;
transition: all, 0.3s;
}
.header__nav__menu ul li .dropdown li {
display: block;
margin-right: 0;
}
.header__nav__menu ul li .dropdown li a {
font-size: 14px;
color: white;
padding: 8px 20px;
text-transform: capitalize;
}
.header__nav__menu ul li .dropdown li a:after {
display: none;
}
.header__nav__menu ul li a {
font-size: 15px;
font-family: "Play", sans-serif;
color: black;
display: block;
text-transform: uppercase;
position: relative;
padding: 6px 0;
}
.header__nav__menu ul li a:after {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 2px;
background: #00bfe7;
content: "";
-webkit-transform: scale(0);
-ms-transform: scale(0);
transform: scale(0);
-webkit-transition: all, 0.3s;
-o-transition: all, 0.3s;
transition: all, 0.3s;
}
/*Settings Dropdown*/
.header__nav__settings {
display: inline-block;
position: relative;
padding-left: 50px;
}
.header__nav__settings:before {
position: absolute;
left: 0;
top: 4px;
height: 13px;
width: 2px;
background: rgba(225, 225, 225, 0.2);
content: "";
}
.header__nav__settings a {
color: black;
font-size: 15px;
}
.header__nav__settings a:last-child {
margin-right: 0;
}
.slicknav_menu {
display: none;
}
/*Settings Dropdown Content*/
.header__nav__settings ul a {
list-style: none;
display: inline-block;
margin-right: 45px;
position: relative;
}
.header__nav__settings ul a i.active a:after {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
.header__nav__settings ul a i:hover a:after {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
.header__nav__settings ul:hover .dropdown {
top: 34px;
opacity: 1;
visibility: visible;
}
.header__nav__settings ul .dropdown li a {
font-size: 14px;
color: white;
padding: 8px 20px;
text-transform: capitalize;
}
.header__nav__settings ul .dropdown {
position: absolute;
left: 0;
top: 60px;
width: 140px;
background: black;
text-align: left;
padding: 2px 0;
z-index: 9;
opacity: 0;
visibility: hidden;
-webkit-transition: all, 0.3s;
-o-transition: all, 0.3s;
transition: all, 0.3s;
}
.header__nav__settings ul .dropdown li {
display: block;
margin-right: 0;
}
.header__nav__settings ul li .dropdown li a {
font-size: 14px;
color: white;
padding: 8px 20px;
text-transform: capitalize;
}
.header__nav__settings ul a .dropdown li a:after {
display: none;
}
.header__nav__settings ul li a {
font-size: 15px;
font-family: "Play", sans-serif;
color: black;
display: block;
text-transform: uppercase;
position: relative;
padding: 6px 0;
}
.header__nav__settings ul li a:after {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 2px;
background: #00bfe7;
content: "";
-webkit-transform: scale(0);
-ms-transform: scale(0);
transform: scale(0);
-webkit-transition: all, 0.3s;
-o-transition: all, 0.3s;
transition: all, 0.3s;
}
Thank u in adavnce for the help!!!
Your code is wrong because your wrote <i> instead of <li> and you didn't close the <a> where you should. This is the code corrected:
.header {
position: absolute;
left: 0;
top: 0;
width: 100%;
background: transparent;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
z-index: 9;
}
.header__nav__menu {
display: inline-block;
margin-right: 45px;
}
.header__nav__menu ul li {
list-style: none;
display: inline-block;
margin-right: 45px;
position: relative;
}
.header__nav__menu ul li.active a:after {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
.header__nav__menu ul li:hover a:after {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
.header__nav__menu ul li:hover .dropdown {
top: 34px;
opacity: 1;
visibility: visible;
}
.header__nav__menu ul li:last-child {
margin-right: 0;
}
.header__nav__menu ul li .dropdown {
position: absolute;
left: 0;
top: 60px;
width: 140px;
background: black;
text-align: left;
padding: 2px 0;
z-index: 9;
opacity: 0;
visibility: hidden;
-webkit-transition: all, 0.3s;
-o-transition: all, 0.3s;
transition: all, 0.3s;
}
.header__nav__menu ul li .dropdown li {
display: block;
margin-right: 0;
}
.header__nav__menu ul li .dropdown li a {
font-size: 14px;
color: white;
padding: 8px 20px;
text-transform: capitalize;
}
.header__nav__menu ul li .dropdown li a:after {
display: none;
}
.header__nav__menu ul li a {
font-size: 15px;
font-family: "Play", sans-serif;
color: black;
display: block;
text-transform: uppercase;
position: relative;
padding: 6px 0;
}
.header__nav__menu ul li a:after {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 2px;
background: #00bfe7;
content: "";
-webkit-transform: scale(0);
-ms-transform: scale(0);
transform: scale(0);
-webkit-transition: all, 0.3s;
-o-transition: all, 0.3s;
transition: all, 0.3s;
}
/*Settings Dropdown*/
.header__nav__settings {
display: inline-block;
position: relative;
padding-left: 50px;
}
.header__nav__settings:before {
position: absolute;
left: 0;
top: 4px;
height: 13px;
width: 2px;
background: rgba(225, 225, 225, 0.2);
content: "";
}
.header__nav__settings a {
color: black;
font-size: 15px;
}
.header__nav__settings a:last-child {
margin-right: 0;
}
.slicknav_menu {
display: none;
}
/*Settings Dropdown Content*/
.header__nav__settings ul a {
list-style: none;
display: inline-block;
margin-right: 45px;
position: relative;
}
.header__nav__settings ul a i.active a:after {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
.header__nav__settings ul a i:hover a:after {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
.header__nav__settings ul:hover .dropdown {
top: 34px;
opacity: 1;
visibility: visible;
}
.header__nav__settings ul .dropdown li a {
font-size: 14px;
color: white;
padding: 8px 20px;
text-transform: capitalize;
}
.header__nav__settings ul .dropdown {
position: absolute;
left: 0;
top: 60px;
width: 140px;
background: black;
text-align: left;
padding: 2px 0;
z-index: 9;
opacity: 0;
visibility: hidden;
-webkit-transition: all, 0.3s;
-o-transition: all, 0.3s;
transition: all, 0.3s;
}
.header__nav__settings ul .dropdown li {
display: block;
margin-right: 0;
}
.header__nav__settings ul li .dropdown li a {
font-size: 14px;
color: white;
padding: 8px 20px;
text-transform: capitalize;
}
.header__nav__settings ul a .dropdown li a:after {
display: none;
}
.header__nav__settings ul li a {
font-size: 15px;
font-family: "Play", sans-serif;
color: black;
display: block;
text-transform: uppercase;
position: relative;
padding: 6px 0;
}
.header__nav__settings ul li a:after {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 2px;
background: #00bfe7;
content: "";
-webkit-transform: scale(0);
-ms-transform: scale(0);
transform: scale(0);
-webkit-transition: all, 0.3s;
-o-transition: all, 0.3s;
transition: all, 0.3s;
}
<!-- Google Font -->
<link href="https://fonts.googleapis.com/css2?family=Play:wght#400;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Josefin+Sans:wght#300;400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
<header class="header">
<div class="container">
<div class="row">
<div class="col-lg-2">
<div class="header__logo">
<img src="img/logo.png" alt="">
</div>
</div>
<div class="col-lg-10">
<div class="header__nav__option">
<nav class="header__nav__menu mobile-menu">
<ul>
<li>Pages
<ul class="dropdown">
<li>About</li>
<li>Portfolio</li>
<li>Blog</li>
<li>Blog Details</li>
</ul>
</li>
</ul>
</nav>
<div class="header__nav__settings">
<ul>
<li class="fa fa-gear">
<ul class="dropdown">
<li>Portfolio</li>
<li>Blog</li>
<li>Blog Details</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
<div id="mobile-menu-wrap"></div>
</div>
</header>
I'm trying to get the background to each nav link fixed. I want it to be uniform behind each link, meaning equal on both left and right side.
Link to the actual webpage.
See the code below the picture.
Thanks.
<div class="top-nav">
<span class="menu"><img src="images/menu.png" alt=""></span>
<ul class="nav1" style="margin-top: .5em;">
<li class="hvr-sweep-to-bottom active">Home
</li>
<li class="hvr-sweep-to-bottom">Fleet Management
<ul class="level_1">
<li>Basic
</li>
<li>Basic Plus
</li>
<li>Ultra
</li>
<li>Ultra Plus
</li>
</ul>
</li>
<li class="hvr-sweep-to-bottom">Broker Agency
</li>
<li class="hvr-sweep-to-bottom">Maintenance
</li>
<li class="hvr-sweep-to-bottom">Drivers
</li>
<li class="hvr-sweep-to-bottom">Contact
</li>
<div class="clearfix"></div>
</ul>
And the CSS
.top-nav {
float: right;
width: 80%;
position: absolute;
left: 27%;
top: 20%;
}
.top-nav ul {
padding: 0;
margin: 0;
}
.top-nav ul li {
display: inline-block;
margin-right: .4em;
float: left;
position: relative;
}
.top-nav ul li.active {
background: #bb1e10;
}
.top-nav ul li a {
color: #FFF;
font-size: 18px;
margin-right: .4em;
float: left;
padding: 1em 0em 1em 1.4em;
text-align: center;
width: 79%;
}
.top-nav ul li a i {
display: block;
margin-top: 1em;
color: #FFF;
font-size: 11px;
font-style: italic;
}
.top-nav ul ul {
display: none;
left: 0;
float: left;
position: relative;
}
.top-nav ul ul li {
float: none;
width: 200px;
z-index: 1;
}
.top-nav ul ul li a {
padding: 5px 5px;
}
.top-nav ul li:hover > ul {
display: block;
}
/* Sweep To Bottom */
.hvr-sweep-to-bottom {
display: inline-block;
vertical-align: middle;
-webkit-transform: translateZ(0);
-o-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
-webkit-backface-visibility: hidden;
-o-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
backface-visibility: hidden;
-moz-osx-font-smoothing: grayscale;
-ms-osx-font-smoothing: grayscale;
-o-osx-font-smoothing: grayscale;
position: relative;
-webkit-transition-property: color;
-o-transition-property: color;
-moz-transition-property: color;
-ms-transition-property: color;
transition-property: color;
-webkit-transition-duration: 0.3s;
-o-transition-duration: 0.3s;
-moz-transition-duration: 0.3s;
-ms-transition-duration: 0.3s;
transition-duration: 0.3s;
}
.hvr-sweep-to-bottom:before {
content: "";
position: absolute;
z-index: -1;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #bb1e10;
-webkit-transform: scaleY(0);
-o-transform: scaleY(0);
-moz-transform: scaleY(0);
-ms-transform: scaleY(0);
transform: scaleY(0);
-webkit-transform-origin: 50% 0;
-o-transform-origin: 50% 0;
-moz-transform-origin: 50% 0;
-ms-transform-origin: 50% 0;
transform-origin: 50% 0;
-webkit-transition-property: transform;
-o-transition-property: transform;
-moz-transition-property: transform;
-ms-transition-property: transform;
transition-property: transform;
-webkit-transition-duration: 0.3s;
-o-transition-duration: 0.3s;
-moz-transition-duration: 0.3s;
-ms-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-timing-function: ease-out;
-o-transition-timing-function: ease-out;
-moz-transition-timing-function: ease-out;
-ms-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
.hvr-sweep-to-bottom:hover,
.hvr-sweep-to-bottom:focus,
.hvr-sweep-to-bottom:active {
color: white;
}
.hvr-sweep-to-bottom:hover:before,
.hvr-sweep-to-bottom:focus:before,
.hvr-sweep-to-bottom:active:before {
-webkit-transform: scaleY(1);
transform: scaleY(1);
}
/*---*/
You have added some JavaScript as well (for animations and swipe downs). I was able to mimic something, which doesn't have animations, but works as expected. Have a look here in the full screen:
* {
margin: 0;
padding: 0;
list-style: none;
box-sizing: border-box;
font-family: 'Segoe UI';
}
a {
text-decoration: none;
}
.nav {
display: block;
}
.nav > li {
display: inline-block;
position: relative;
}
.nav > li:hover,
.nav > li.active {
background-color: #f00;
color: #fff;
}
.nav a {
display: block;
padding: 10px;
color: inherit;
}
.nav ul {
display: none;
position: absolute;
left: 0;
right: 0;
background-color: #f00;
color: #fff;
}
.nav > li:hover ul {
display: block;
}
<ul class="nav">
<li class="hvr-sweep-to-bottom active">
Home
</li>
<li class="hvr-sweep-to-bottom">
Fleet Management
<ul>
<li>Basic</li>
<li>Basic Plus</li>
<li>Ultra</li>
<li>Ultra Plus</li>
</ul>
</li>
<li class="hvr-sweep-to-bottom">
Broker Agency
</li>
<li class="hvr-sweep-to-bottom">
Maintenance
</li>
<li class="hvr-sweep-to-bottom">
Drivers
</li>
<li class="hvr-sweep-to-bottom">
Contact
</li>
</ul>
Update
To fix your issue, please add this to the bottom of the style.css:
.nav {
display: block;
margin: 25px;
float: left;
}
.nav > li {
display: inline-block;
position: relative;
}
.nav > li:hover,
.nav > li.active {
background-color: #f00;
color: #fff;
}
.nav a {
display: block;
padding: 10px;
color: #fff;
}
.nav ul {
display: none;
position: absolute;
left: 0;
right: 0;
background-color: #f00;
color: #fff;
z-index: 1;
}
.nav > li:hover ul {
display: block;
}
So this gives an output like this:
My Homepage-Menu-Point "Software" should stay opened if you click on it!
See on my Test-Homepage!
I've tested to add "li:focus" and "li:active" to my lowermost CSS-Tag, but nothing worked. I also tried it with jQuery, without success!
The HTML-Code:
<nav id="cNav">
<div class="Nav">
<ul>
<li>G</li>
<li>Home</li>
<li>Software
<ul>
<li>Android</li>
<li>Windows</li>
</ul>
</li>
<li>Über</li>
</ul>
</div>
</nav>
The CSS-Code:
#cNav {
background-color: rgb(5, 90, 160);
margin: 0;
padding: 0;
width: 100%;
}
.Nav {
font-weight: bold;
font-size: 22pt;
margin: 0;
padding: 0;
}
.Nav ul {
padding: 0;
margin-top: 0;
margin-bottom: 0;
position: relative;
width: 100%;
text-align: center;
}
.Nav ul li {
display: inline-block;
position: relative;
padding-left: 2em;
padding-right: 2em;
padding-top: 0.4em;
padding-bottom: 0.4em;
}
.Nav ul li a {
outline: 0;
color: white;
position: relative;
text-decoration: none;
transition: color 0.3s;
}
.Nav ul li a::after {
position: absolute;
top: 100%;
left: 0;
width: 100%;
height: 4px;
background: white;
content: '';
opacity: 0;
-webkit-transition: opacity 0.3s, -webkit-transform 0.3s;
-moz-transition: opacity 0.3s, -moz-transform 0.3s;
transition: opacity 0.3s, transform 0.3s;
-webkit-transform: translateY(10px);
-moz-transform: translateY(10px);
transform: translateY(10px);
margin: 0;
}
.Nav ul li a:hover::after {
opacity: 1;
-webkit-transform: translateY(0px);
-moz-transform: translateY(0px);
transform: translateY(0px);
}
.Nav ul ul {
display: none;
white-space: nowrap;
position: absolute;
text-align: center;
top: 100%;
margin-left: -5.3em;
}
.Nav ul ul li {
background-color: rgb(5, 90, 160);
border-top: medium solid rgba(0,115,209,1.00);
margin-right: -1em;
}
.Nav ul li:hover > ul {
display: block;
}
If you want your Homepage-Menu-Point "Software" staying opened if you click on it, and you want to use jQuery, this might be a possible solution:
Add an id to the li with software:
<li id="software">Software
Then you can use this to set the css display property of the ul to block:
$(document).ready(function() {
$("#software ul").click(function() {
$(this).css("display", "block");
});
});
Snippet:
$(document).ready(function() {
$("#software ul").click(function() {
$(this).css("display", "block");
});
});
#cNav {
background-color: rgb(5, 90, 160);
margin: 0;
padding: 0;
width: 100%;
}
.Nav {
font-weight: bold;
font-size: 22pt;
margin: 0;
padding: 0;
}
.Nav ul {
padding: 0;
margin-top: 0;
margin-bottom: 0;
position: relative;
width: 100%;
text-align: center;
}
.Nav ul li {
display: inline-block;
position: relative;
padding-left: 2em;
padding-right: 2em;
padding-top: 0.4em;
padding-bottom: 0.4em;
}
.Nav ul li a {
outline: 0;
color: white;
position: relative;
text-decoration: none;
transition: color 0.3s;
}
.Nav ul li a::after {
position: absolute;
top: 100%;
left: 0;
width: 100%;
height: 4px;
background: white;
content: '';
opacity: 0;
-webkit-transition: opacity 0.3s, -webkit-transform 0.3s;
-moz-transition: opacity 0.3s, -moz-transform 0.3s;
transition: opacity 0.3s, transform 0.3s;
-webkit-transform: translateY(10px);
-moz-transform: translateY(10px);
transform: translateY(10px);
margin: 0;
}
.Nav ul li a:hover::after {
opacity: 1;
-webkit-transform: translateY(0px);
-moz-transform: translateY(0px);
transform: translateY(0px);
}
.Nav ul ul {
display: none;
white-space: nowrap;
position: absolute;
text-align: center;
top: 100%;
margin-left: -5.3em;
}
.Nav ul ul li {
background-color: rgb(5, 90, 160);
border-top: medium solid rgba(0,115,209,1.00);
margin-right: -1em;
}
.Nav ul li:hover > ul {
display: block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav id="cNav">
<div class="Nav">
<ul>
<li>G</li>
<li>Home</li>
<li id="software">Software
<ul>
<li>Android</li>
<li>Windows</li>
</ul>
</li>
<li>Über</li>
</ul>
</div>
</nav>
I am trying to generate a pure HTML/CSS menu with arrows pointing to the right. As long as the active state is the first tab everything looks fine (http://jsfiddle.net/q03wma6u/). But when the active class moves to the second tab, the border and the arrow are not positioned togehter (http://jsfiddle.net/q03wma6u/1/).
Is there a way to generate this menu just using HTML/CSS?
ol.tabs {
-moz-transition: opacity 0.3s linear;
-o-transition: opacity 0.3s linear;
-webkit-transition: opacity 0.3s linear;
transition: opacity 0.3s linear;
margin: 0;
padding: 0;
list-style: none;
display: table;
table-layout: fixed;
width: 100%;
}
ol.tabs li {
position: relative;
display: table-cell;
overflow: hidden;
margin: 0;
padding: 0;
text-align: center;
text-transform: uppercase;
background-color: #ccc;
-moz-transition: background-color 0.3s linear;
-o-transition: background-color 0.3s linear;
-webkit-transition: background-color 0.3s linear;
transition: background-color 0.3s linear;
}
ol.tabs li:after {
content: " ";
display: block;
position: absolute;
top: 4px;
right: 6px;
width: 32px;
height: 32px;
border: 1px solid #4a4a4a;
border-bottom: none;
border-left: none;
border-radius: 2px;
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
ol.tabs li:last-child:after {
border: none;
}
ol.tabs li:last-child a:before {
border: none;
}
ol.tabs li.active a {
background-color: #fff;
-moz-transition: background-color 0.3s linear;
-o-transition: background-color 0.3s linear;
-webkit-transition: background-color 0.3s linear;
transition: background-color 0.3s linear;
}
ol.tabs li.active a:before {
content: " ";
display: block;
position: absolute;
top: 0px;
right: 0px;
width: 0px;
height: 0px;
border-style: solid;
border-width: 20px 0 20px 20px;
border-color: transparent transparent transparent #fff;
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
ol.tabs li.active a:after {
content: " ";
display: block;
position: absolute;
top: 0px;
left: 0px;
width: 0px;
height: 0px;
border-style: solid;
border-width: 20px 0 20px 20px;
border-color: transparent transparent transparent #ccc;
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
ol.tabs li:first-child a:after {
border: none;
}
ol.tabs li a {
display: block;
padding: 10px 0px;
margin-right: 20px;
color: #4a4a4a;
font-weight: bold;
text-decoration: underline;
}
ol.tabs li a.disabled {
cursor: initial;
font-weight: normal;
text-decoration: none;
}
ol.tabs li a.disabled:hover {
text-decoration: none;
}
<ol class="tabs">
<li class="step1 active">Step 1</li>
<li class="step2">Step 2</li>
<li class="step3">Step 3</li>
<li class="step4">Step 4</li>
</ol>
CSS
.breadcrumb {
list-style: none;
overflow: hidden;
font: 18px Helvetica, Arial, Sans-Serif;
}
.breadcrumb li {
float: left;
}
.breadcrumb li a {
color: white;
text-decoration: none;
padding: 10px 0 10px 55px;
background: brown; /* fallback color */
background: hsla(34,85%,35%,1);
position: relative;
display: block;
float: left;
}
.breadcrumb li a:after {
content: " ";
display: block;
width: 0;
height: 0;
border-top: 50px solid transparent; /* Go big on the size, and let overflow hide */
border-bottom: 50px solid transparent;
border-left: 30px solid hsla(34,85%,35%,1);
position: absolute;
top: 50%;
margin-top: -50px;
left: 100%;
z-index: 2;
}
.breadcrumb li a:before {
content: " ";
display: block;
width: 0;
height: 0;
border-top: 50px solid transparent; /* Go big on the size, and let overflow hide */
border-bottom: 50px solid transparent;
border-left: 30px solid white;
position: absolute;
top: 50%;
margin-top: -50px;
margin-left: 1px;
left: 100%;
z-index: 1;
}
.breadcrumb li:first-child a {
padding-left: 10px;
}
.breadcrumb li a:hover { background: hsla(34,85%,25%,1); }
.breadcrumb li a:hover:after { border-left-color: hsla(34,85%,25%,1) !important; }
<ul class="breadcrumb">
<li>Home</li>
<li>Vehicles</li>
<li>Vans</li>
<li>Camper Vans</li>
</ul>
change your css as mentioned in blow link
https://css-tricks.com/examples/TriangleBreadcrumbs/
How's this:
.tabs {
list-style: none;
padding: 0;
margin: 0;
}
.tabs a {
display: table-cell;
text-align: center;
vertical-align: middle;
color: #4a4a4a;
text-decoration: none;
text-transform: uppercase;
}
.tabs > li {
float: left;
position: relative;
border: 1px solid #7B7B7B;
border-right: none;
width: 140px;
height: 50px;
background: #cccccc;
cursor: pointer;
display: table;
}
.tabs > li:before {
position: absolute;
top: 50%;
right: 0;
margin: -15px -13px;
border-top: solid 1px #7B7B7B;
border-right: solid 1px #7B7B7B;
width: 25px;
/* .tabs > li height/2 */
height: 29px;
/* .tabs > li height/sqrt(3) */
transform: rotate(30deg) skewY(30deg);
/* create a rhombus */
-ms-transform: rotate(30deg) skewY(30deg);
/* IE 9 */
-webkit-transform: rotate(30deg) skewY(30deg);
/* Safari and Chrome */
background: #cccccc;
/* 49.1deg = atan(1.15) = atan(height/width) */
/* percentages are 100 - .tabs > li percentages*/
content: '';
z-index: 1;
}
.tabs > li:after {
position: absolute;
top: 0;
right: 0;
bottom: 0;
width: 40px;
background: #cccccc;
content: '';
z-index: 2;
}
.tabs > li.active,
.tabs > li.active:before,
.tabs > li.active:after {
background: #ffffff;
}
<ol class="tabs">
<li class="step1">Step 1</li>
<li class="step2 active">Step 2</li>
<li class="step3">Step 3</li>
<li class="step4">Step 4</li>
</ol>
Without borders and square end box for the end li:
.tabs {
list-style: none;
padding: 0;
margin: 0;
}
.tabs a {
display: table-cell;
text-align: center;
vertical-align: middle;
color: #4a4a4a;
text-decoration: none;
text-transform: uppercase;
}
.tabs > li {
float: left;
position: relative;
border-right: none;
width: 140px;
height: 50px;
background: #cccccc;
cursor: pointer;
display: table;
}
.tabs > li:before {
position: absolute;
top: 50%;
right: 0;
margin: -15px -13px;
border-top: solid 1px #7B7B7B;
border-right: solid 1px #7B7B7B;
width: 25px;
height: 29px;
transform: rotate(30deg) skewY(30deg);
-ms-transform: rotate(30deg) skewY(30deg);
-webkit-transform: rotate(30deg) skewY(30deg);
background: #cccccc;
content: '';
z-index: 1;
}
.tabs > li:after {
position: absolute;
top: 0;
right: 0;
bottom: 0;
width: 40px;
background: #cccccc;
content: '';
z-index: 2;
}
.tabs > li.active,
.tabs > li.active:before,
.tabs > li.active:after {
background: #ffffff;
}
.tabs > li:last-child:before,
.tabs > li:last-child:after {display:none; content:none;}
<ol class="tabs">
<li class="step1">Step 1</li>
<li class="step2 active">Step 2</li>
<li class="step3">Step 3</li>
<li class="step4">Step 4</li>
</ol>
I can't seem to find the issue that is causing my links to only be clicked on the white portion. It's a "3D" button by that, I mean it is a link with CSS rotate transitions. I'm not able to find any solutions so I'm looking for some help!
Here's the codepen link.
HTML:
<nav>
<ul>
<li>Home
</li>
<li>Plans
</li>
<li>Forums
</li>
<li>Team
</li>
</ul>
</nav>
CSS
* {
box-sizing: border-box;
}
nav {
background: #e9e9e9;
margin: -1rem 0rem;
z-index: 0;
}
nav ul {
list-style: none;
}
nav ul li {
display: inline-block;
text-transform: uppercase;
font-size: 1.5rem;
letter-spacing: 0.05rem;
}
nav ul li a {
display: inline-block;
padding: 1rem;
color: #000;
text-decoration: none;
transition: transform 0.3s ease 0s;
transform-origin: 50% 0px 0px;
transform-style: preserve-3d;
}
nav ul li a.current {
color: #ffc400;
}
nav ul li a: hover {
background: #e9e9e9;
color: #000;
transform: rotateX(90deg) translateY(-22px);
}
nav ul li a::before {
position: absolute;
top: 100%;
left: 0px;
width: 100%;
padding: 4px 0px;
text-align: center;
line-height: 50px;
background: none repeat scroll 0% 0% #ffc400;
color: #FFF;
content: attr(data-hover);
transition: #ffc400 0.3s ease 0s;
transform: rotateX(-90 deg);
transform -origin: 50% 0px 0px;
}
Well the issue is that you're translating the link out of view so it cannot be clicked:
nav ul li a:hover {
background: #e9e9e9;
color: #000;
transform: rotateX(90deg) translateY(-22px);
}
The dead simple solution to this problem would be simply put an a element around the li element and change the current a element to a div, like so:
This way, the div and li elements that are being translated and rotated are surrounded by the clickable link.
<a href="#">
<li>
<div data-hover="Forums">Forums</div>
</li>
</a>
CSS:
* {
box-sizing: border-box;
}
nav {
background: #e9e9e9;
margin: -1rem 0rem;
z-index: 0;
}
nav ul {
list-style: none;
}
nav ul li {
display: inline-block;
text-transform: uppercase;
font-size: 1.5rem;
letter-spacing: 0.05rem;
}
nav ul li div {
display: inline-block;
padding: 1rem;
color: #000;
text-decoration: none;
transition: transform 0.3s ease 0s;
transform-origin: 50% 0px 0px;
transform-style: preserve-3d;
}
nav ul li div.current {
color: #ffc400;
}
nav ul li div:hover {
background: #e9e9e9;
color: #000;
transform: rotateX(90deg) translateY(-22px);
}
nav ul li div::before {
position: absolute;
top: 100%;
left: 0px;
width: 100%;
padding: 4px 0px;
text-align: center;
line-height: 50px;
background: none repeat scroll 0% 0% #ffc400;
color: #FFF;
content: attr(data-hover);
transition: #ffc400 0.3s ease 0s;
transform: rotateX(-90deg);
transform-origin: 50% 0px 0px;
}
And then adding a element styling to make everything work out:
nav ul a {
text-decoration: none;
}
Here's the updated pen.