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>
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>
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
please check out this code pen link
want to make the square beside home to triangle upside down. when i hover - its working correctly
https://codepen.io/shaswat/pen/gXLBwo
please help me to make that square to triangle .creating a navigation bar
after I hover its working correctly by transforming to upside
/* Menu CSS */#cssmenu,
#cssmenu > ul {
background: black;
padding-bottom: 3px;
}
#cssmenu:before,
#cssmenu:after,
#cssmenu > ul:before,
#cssmenu > ul:after {
content: "";
display: table;
box-sizing: border-box;
}
#cssmenu:after,
#cssmenu > ul:after {
clear: both;
}
#cssmenu {
width: auto;
zoom: 1;
}
#cssmenu > ul {
background: blue;
margin: 0;
padding: 0;
position: relative;
}
#cssmenu > ul li {
margin: 0;
padding: 0;
list-style: none;
}
#cssmenu > ul > li {
float: left;
position: relative;
}
#cssmenu > ul > li > a {
padding: 15px 25px;
display: block;
color: white;
font-size: 13px;
text-decoration: none;
text-transform: uppercase;
text-shadow: 0 -1px 0 #0d0d0d;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.7);
}
#cssmenu > ul > li:hover > a {
background: red;
text-shadow: 0 -1px 0 #97321f;
text-shadow: 0 -1px 0 rgba(122, 42, 26, 0.64);
}
#cssmenu > ul > li.active > a,
#cssmenu > ul > li > a.active {
background: grey;
}
/* Childs */
#cssmenu > ul ul {
opacity: 0;
visibility: hidden;
position: absolute;
top: 50px;
background: green;
margin: 0;
padding: 0;
z-index: -1;
}
#cssmenu > ul li:hover ul {
opacity: 1;
visibility: visible;
margin: 0;
color: #000;
z-index: 2;
top: 50px;
left: 0;
}
#cssmenu > ul ul:before {
content: "";
position: absolute;
top: -10px;
width: 100%;
height: 18px;
background: transparent;
}
#cssmenu > ul ul li {
list-style: none;
padding: 0;
margin: 0;
width: 100%;
}
#cssmenu > ul ul li a {
padding: 15px 26px;
display: block;
color: white;
font-size: 14px;
text-decoration: none;
width: 150px;
border-left: 4px solid transparent;
-webkit-transition: all 0.50s ease-in-out;
-moz-transition: all 0.50s ease-in-out;
-ms-transition: all 0.50s ease-in-out;
transition: all 0.50s ease-in-out;
}
#cssmenu > ul ul li a:hover {
border-left: 10px solid #d64e34;
background: grey;
}
#cssmenu > ul ul li a:active {
background: green;
}
#cssmenu li a:first-child:nth-last-child(2):before {
content:"";
position: absolute;
height: 0;
width: 0;
border: 8px solid orange;
top: 40%;
right: 5px;
}
#cssmenu li:hover > a:first-child:nth-last-child(2):before {
border: 8px solid transparent;
border-bottom-color: orange;
margin-top: -5px;
}
<div id='cssmenu'>
<ul>
<li><a href='#'>Home</a>
<ul>
<li><a href='#'>Product 1</a></li>
<li><a href='#'>Product 2</a></li>
<li><a href='#'>Product 3</a></li>
</ul>
</li>
<li><a class='active' href='#'>Products</a></li>
<li><a href='#'>About</a></li>
<li><a href='#'>Contact</a></li>
</ul>
</div>
On the line 119 replace orange with transparent. And add border-top-color: orange;. If you make border-bottom-color instead of border-top-color arrow will be reversed.
border: 8px solid transparent;
border-top-color: orange;
Change the code of #cssmenu li a:first-child:nth-last-child(2):before like this :
#cssmenu li a:first-child:nth-last-child(2):before {
content: "";
position: absolute;
height: 0;
width: 0;
border: 8px solid transparent;
border-top-color: orange;
top: 40%;
right: 5px;
}
the full code :
/* Menu CSS */
#cssmenu,
#cssmenu>ul {
background: black;
padding-bottom: 3px;
}
#cssmenu:before,
#cssmenu:after,
#cssmenu>ul:before,
#cssmenu>ul:after {
content: "";
display: table;
box-sizing: border-box;
}
#cssmenu:after,
#cssmenu>ul:after {
clear: both;
}
#cssmenu {
width: auto;
zoom: 1;
}
#cssmenu>ul {
background: blue;
margin: 0;
padding: 0;
position: relative;
}
#cssmenu>ul li {
margin: 0;
padding: 0;
list-style: none;
}
#cssmenu>ul>li {
float: left;
position: relative;
}
#cssmenu>ul>li>a {
padding: 15px 25px;
display: block;
color: white;
font-size: 13px;
text-decoration: none;
text-transform: uppercase;
text-shadow: 0 -1px 0 #0d0d0d;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.7);
}
#cssmenu>ul>li:hover>a {
background: red;
text-shadow: 0 -1px 0 #97321f;
text-shadow: 0 -1px 0 rgba(122, 42, 26, 0.64);
}
#cssmenu>ul>li.active>a,
#cssmenu>ul>li>a.active {
background: grey;
}
/* Childs */
#cssmenu>ul ul {
opacity: 0;
visibility: hidden;
position: absolute;
top: 50px;
background: green;
margin: 0;
padding: 0;
z-index: -1;
}
#cssmenu>ul li:hover ul {
opacity: 1;
visibility: visible;
margin: 0;
color: #000;
z-index: 2;
top: 50px;
left: 0;
}
#cssmenu>ul ul:before {
content: "";
position: absolute;
top: -10px;
width: 100%;
height: 18px;
background: transparent;
}
#cssmenu>ul ul li {
list-style: none;
padding: 0;
margin: 0;
width: 100%;
}
#cssmenu>ul ul li a {
padding: 15px 26px;
display: block;
color: white;
font-size: 14px;
text-decoration: none;
width: 150px;
border-left: 4px solid transparent;
-webkit-transition: all 0.50s ease-in-out;
-moz-transition: all 0.50s ease-in-out;
-ms-transition: all 0.50s ease-in-out;
transition: all 0.50s ease-in-out;
}
#cssmenu>ul ul li a:hover {
border-left: 10px solid #d64e34;
background: grey;
}
#cssmenu>ul ul li a:active {
background: green;
}
#cssmenu li a:first-child:nth-last-child(2):before {
content: "";
position: absolute;
height: 0;
width: 0;
border: 8px solid transparent;
border-top-color: orange;
top: 40%;
right: 5px;
}
#cssmenu li:hover>a:first-child:nth-last-child(2):before {
border: 8px solid transparent;
border-bottom-color: orange;
margin-top: -5px;
}
<div id='cssmenu'>
<ul>
<li><a href='#'>Home</a>
<ul>
<li><a href='#'>Product 1</a></li>
<li><a href='#'>Product 2</a></li>
<li><a href='#'>Product 3</a></li>
</ul>
</li>
<li><a class='active' href='#'>Products</a></li>
<li><a href='#'>About</a></li>
<li><a href='#'>Contact</a></li>
</ul>
</div>
Instead of having #cssmenu li a:first-child:nth-last-child(2):before have border: 8px solid orange; replace it with border: 8px solid transparent; and border-top-color: orange;. This will give you a down arrow and when you hover it will turn into an up arrow.
As an alternative, you could use a font. Replace the last two rules with this:
#cssmenu>ul>li>a::after {
content: "⏷";
position: absolute;
line-height: .5;
font-size: 24px;
transform: rotate(0deg) translateY(0);
margin-left: 5px;
color:orange;
transition:.5s ease;
}
#cssmenu>ul>li:hover>a::after {
transform:rotate(180deg) translate(5px,-5px);
transform-origin:center;
transition:.5s ease;
}
Demo
/* Menu CSS */
#cssmenu,
#cssmenu>ul {
background: black;
padding-bottom: 3px;
}
#cssmenu:before,
#cssmenu:after,
#cssmenu>ul:before,
#cssmenu>ul:after {
content: "";
display: table;
box-sizing: border-box;
}
#cssmenu:after,
#cssmenu>ul:after {
clear: both;
}
#cssmenu {
width: auto;
zoom: 1;
}
#cssmenu>ul {
background: blue;
margin: 0;
padding: 0;
position: relative;
}
#cssmenu>ul li {
margin: 0;
padding: 0;
list-style: none;
}
#cssmenu>ul>li {
float: left;
position: relative;
}
#cssmenu>ul>li>a {
padding: 15px 25px;
display: block;
color: white;
font-size: 13px;
text-decoration: none;
text-transform: uppercase;
text-shadow: 0 -1px 0 #0d0d0d;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.7);
}
#cssmenu>ul>li:hover>a {
background: red;
text-shadow: 0 -1px 0 #97321f;
text-shadow: 0 -1px 0 rgba(122, 42, 26, 0.64);
}
#cssmenu>ul>li.active>a,
#cssmenu>ul>li>a.active {
background: grey;
}
/* Childs */
#cssmenu>ul ul {
opacity: 0;
visibility: hidden;
position: absolute;
top: 50px;
background: green;
margin: 0;
padding: 0;
z-index: -1;
}
#cssmenu>ul li:hover ul {
opacity: 1;
visibility: visible;
margin: 0;
color: #000;
z-index: 2;
top: 50px;
left: 0;
}
#cssmenu>ul ul:before {
content: "";
position: absolute;
top: -10px;
width: 100%;
height: 18px;
background: transparent;
}
#cssmenu>ul ul li {
list-style: none;
padding: 0;
margin: 0;
width: 100%;
}
#cssmenu>ul ul li a {
padding: 15px 26px;
display: block;
color: white;
font-size: 14px;
text-decoration: none;
width: 150px;
border-left: 4px solid transparent;
-webkit-transition: all 0.50s ease-in-out;
-moz-transition: all 0.50s ease-in-out;
-ms-transition: all 0.50s ease-in-out;
transition: all 0.50s ease-in-out;
}
#cssmenu>ul ul li a:hover {
border-left: 10px solid #d64e34;
background: grey;
}
#cssmenu>ul ul li a:active {
background: green;
}
#cssmenu>ul>li:first-of-type>a::after {
content: "⏷";
position: absolute;
line-height: .5;
font-size: 24px;
transform: rotate(0deg) translate(-5px,0);
margin-left: 5px;
color:orange;
transition:.5s ease;
}
#cssmenu>ul>li:first-of-type:hover>a::after {
transform:rotate(180deg) translate(5px,-5px);
transform-origin:center;
transition:.5s ease;
}
<div id='cssmenu'>
<ul>
<li><a href='#'>Home</a>
<ul>
<li><a href='#'>Product 1</a></li>
<li><a href='#'>Product 2</a></li>
<li><a href='#'>Product 3</a></li>
</ul>
</li>
<li><a class='active' href='#'>Products</a>
</li>
<li><a href='#'>About</a>
</li>
<li><a href='#'>Contact</a></li>
</ul>
</div>
just change this styles
#cssmenu li a:first-child:nth-last-child(2):before {
content:"";
position: absolute;
height:0;
width: 0;
border-top: 8px solid orange;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
top: 40% ;
right:5px;
}
This question already has answers here:
How to make this arrow in CSS only?
(5 answers)
Closed 6 years ago.
How can i achieve the effect in the below image using css
parent div with divs with triangle egde like in the picture below. if i can achieve this with JS am also open to any good idea
* {
margin: 0;
}
a {
color: #333;
text-decoration: none;
}
nav {
background: #eee;
overflow: hidden;
}
nav li {
display: inline-block;
vertical-align: top;
position: relative;
}
nav li:after {
content: " ";
position: absolute;
right: 0;
top: 0;
bottom: 0;
width: 40px;
transform: rotate(45deg);
background: #999;
}
nav a {
display: block;
padding: 14px 20px;
position: relative;
z-index: 1;
}
nav li a:before {
content: " ";
position: absolute;
right: 3px;
top: 0;
bottom: 0;
width: 40px;
transform: rotate(45deg);
background: #eee;
z-index: -1;
}
<nav>
<ul>
<li>Jewelry and watches
</li>
<li>watches
</li>
<li>Jewelry
</li>
<li>Wrist watches
</li>
</ul>
</nav>
Or you can even simplify it by using one psudo element and using the border property
* {
margin: 0;
}
a {
color: #333;
text-decoration: none;
}
nav {
background: #eee;
overflow: hidden;
box-shadow: 0px 0px 3px 2px rgba(0,0,0,0.25);
margin: 15px;
}
nav li {
display: inline-block;
vertical-align: top;
position: relative;
}
nav li:after {
content: " ";
position: absolute;
right: 0px;
top: -1px;
bottom: 0;
width: 30px;
transform: rotate(45deg);
background: transparent;
height: 30px;
border-right: 1px solid #999;
border-top: 1px solid #999;
}
nav a {
display: block;
padding: 5px 20px;
position: relative;
z-index: 1;
}
<nav>
<ul>
<li>Jewelry and watches
</li>
<li>watches
</li>
<li>Jewelry
</li>
<li>Wrist watches
</li>
</ul>
</nav>
Try this one
HTML
<ul class="breadcrumb">
<li>Home</li>
<li>Vehicles</li>
<li>Vans</li>
<li>Camper Vans</li>
<li>1989 VW Westfalia Vanagon</li>
</ul>
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 65px;
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;
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:nth-child(2) a { background: hsla(34,85%,45%,1); }
.breadcrumb li:nth-child(2) a:after { border-left-color: hsla(34,85%,45%,1); }
.breadcrumb li:nth-child(3) a { background: hsla(34,85%,55%,1); }
.breadcrumb li:nth-child(3) a:after { border-left-color: hsla(34,85%,55%,1); }
.breadcrumb li:nth-child(4) a { background: hsla(34,85%,65%,1); }
.breadcrumb li:nth-child(4) a:after { border-left-color: hsla(34,85%,65%,1); }
.breadcrumb li:nth-child(5) a { background: hsla(34,85%,75%,1); }
.breadcrumb li:nth-child(5) a:after { border-left-color: hsla(34,85%,75%,1); }
.breadcrumb li:last-child a {
background: transparent !important;
color: black;
pointer-events: none;
cursor: default;
}
.breadcrumb li a:hover { background: hsla(34,85%,25%,1); }
.breadcrumb li a:hover:after { border-left-color: hsla(34,85%,25%,1) !important; }
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'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/