I can't select descendant span - html

I am really confused why I can't choose a span inside <a> tag by saying that
ul li a:hover span:first-child:before{
top: -10px;
left: -10px;
opacity: 1; }
This is the similar question I posted yesterday but a little bit different.
Yesterday,
what I wanted to try div wasn't children div however now span is the child of the <a> tag. I will appreciate any help.
body {
margin: 0;
padding: 0;
background: #ccc;
}
.center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.center ul {
margin: 0;
padding: 0;
}
.center ul li {
list-style: none;
display: inline-block;
padding: 10px;
position: relative;
margin: 5px;
font-size: 20px;
position: relative;
}
.center ul li a {
text-decoration: none;
color: white;
}
ul li a:hover span:first-child:before {
top: -10px;
left: -10px;
opacity: 1;
}
.center ul li a span:first-child::before {
position: absolute;
content: '';
width: 8px;
height: 8px;
border-top: 5px solid black;
border-left: 5px solid black;
top: 0px;
left: 0;
opacity: 0.4;
transition: .6s;
}
.center ul li a span:first-child::after {
position: absolute;
content: '';
width: 8px;
height: 8px;
border-top: 5px solid black;
border-right: 5px solid black;
top: 0px;
right: 0;
opacity: 0.4;
transition: .6s;
}
.center ul li a span:last-child::before {
position: absolute;
content: '';
width: 8px;
height: 8px;
border-left: 5px solid black;
border-bottom: 5px solid black;
bottom: 0px;
left: 0;
opacity: 0.4;
transition: .6s;
}
.center ul li a span:last-child::after {
position: absolute;
content: '';
width: 8px;
height: 8px;
border-bottom: 5px solid black;
border-right: 5px solid black;
bottom: 0px;
right: 0;
opacity: 0.4;
transition: .6s;
}
<div class="center">
<ul>
<li>HOME <span></span><span></span></li>
<li>MENU <span></span><span></span></li>
<li>CONTACT <span></span><span></span></li>
<li>PORTFOLIO <span></span><span></span></li>
</ul>
</div>

Place your hover effect after all your pseudo element declarations.
body{
margin: 0;
padding: 0;
background: #ccc;
}
.center{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
}
.center ul{
margin: 0;
padding: 0;
}
.center ul li{
list-style: none;
display: inline-block;
padding: 10px;
position: relative;
margin: 5px;
font-size: 20px;
position: relative;
}
.center ul li a{
text-decoration: none;
color: white;
}
.center ul li a span:first-child::before{
position: absolute;
content: '';
width: 8px;
height: 8px;
border-top: 5px solid black;
border-left: 5px solid black;
top: 0px;
left: 0;
opacity: 0.4;
transition: .6s;
}
.center ul li a span:first-child:after{
position: absolute;
content: '';
width: 8px;
height: 8px;
border-top: 5px solid black;
border-right: 5px solid black;
top: 0px;
right: 0;
opacity: 0.4;
transition: .6s;
}
.center ul li a span:last-child::before{
position: absolute;
content: '';
width: 8px;
height: 8px;
border-left: 5px solid black;
border-bottom: 5px solid black;
bottom: 0px;
left: 0;
opacity: 0.4;
transition: .6s;
}
.center ul li a span:last-child::after{
position: absolute;
content: '';
width: 8px;
height: 8px;
border-bottom: 5px solid black;
border-right: 5px solid black;
bottom: 0px;
right: 0;
opacity: 0.4;
transition: .6s;
}
ul li a:hover span:first-child::before{
top: -10px;
left: -10px;
opacity: 1;
}
I have tested it here: https://jsfiddle.net/9z7r3e8a/5/

Instead of :first-child you should use :first-of-type, because you already have text element in first place (and as first-child). The :first-of-type will select first span element among all children of <a>:
body {
margin: 0;
padding: 0;
background: #ccc;
}
.center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.center ul {
margin: 0;
padding: 0;
}
.center ul li {
list-style: none;
display: inline-block;
padding: 10px;
position: relative;
margin: 5px;
font-size: 20px;
position: relative;
}
.center ul li a {
text-decoration: none;
color: white;
}
ul li a:hover span:first-of-type:before {
top: -10px;
left: -10px;
opacity: 1;
}
.center ul li a span:first-of-type::before {
position: absolute;
content: '';
width: 8px;
height: 8px;
border-top: 5px solid black;
border-left: 5px solid black;
top: 0px;
left: 0;
opacity: 0.4;
transition: .6s;
}
.center ul li a span:first-of-type::after {
position: absolute;
content: '';
width: 8px;
height: 8px;
border-top: 5px solid black;
border-right: 5px solid black;
top: 0px;
right: 0;
opacity: 0.4;
transition: .6s;
}
.center ul li a span:last-of-type::before {
position: absolute;
content: '';
width: 8px;
height: 8px;
border-left: 5px solid black;
border-bottom: 5px solid black;
bottom: 0px;
left: 0;
opacity: 0.4;
transition: .6s;
}
.center ul li a span:last-of-type::after {
position: absolute;
content: '';
width: 8px;
height: 8px;
border-bottom: 5px solid black;
border-right: 5px solid black;
bottom: 0px;
right: 0;
opacity: 0.4;
transition: .6s;
}
.center ul li a:hover span:first-of-type:before {
top: -10px;
left: -10px;
opacity: 1;
}
<div class="center">
<ul>
<li>HOME <span></span><span></span></li>
<li>MENU <span></span><span></span></li>
<li>CONTACT <span></span><span></span></li>
<li>PORTFOLIO <span></span><span></span></li>
</ul>
</div>

Related

Fill entire angled li tag on hover

I made ul (for site navigation) with the left and right borders at an angle.
I'm struggling with requirement that :hover selector fill entire li.
Is there a way to achieve that or do I need to change my approach?
section ul {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: left;
list-style-type: none;
margin: .5em 1em;
}
li {
margin: 0;
border-radius: 1px;
position: relative;
padding: 0.3em 0.8em;
cursor: pointer;
}
li:nth-child(2n+1)::before {
content: "";
border-right: 2px solid black;
transform: rotate(20deg);
display: block;
position: absolute;
top: -2px;
left: -5px;
width: 2px;
height: 120%;
}
li:nth-child(2n)::after {
content: "";
border-right: 2px solid black;
transform: rotate(-20deg);
display: block;
position: absolute;
top: -2px;
left: -5px;
width: 2px;
height: 120%;
}
li:hover {
background-color: black;
color: white;
}
<section>
<ul>
<li><a>Link 1</a></li>
<li><a>Link 2</a></li>
<li><a>Link 3</a></li>
<li><a>Link 4</a></li>
</ul>
</section>
I think you need a different approach, here is an idea using pseudo element and skew:
section ul {
display: flex;
flex-wrap: wrap;
align-items: center;
list-style-type: none;
margin: .5em 1em;
}
li {
position: relative;
padding: 0.3em 0.8em;
cursor: pointer;
z-index: 0;
}
li:before,
li:after {
content: "";
position: absolute;
z-index: -1;
top: 0;
bottom: 0;
width: 70%;
}
li:before {
left: -1px;
border-left: 2px solid #000;
}
li:after {
right: -1px;
border-right: 2px solid #000;
}
li:after,
li:nth-child(odd):before {
transform: skewX(-15deg)
}
li:before,
li:nth-child(odd):after {
transform: skewX(15deg)
}
li:hover {
color: #fff;
}
li:hover:before,
li:hover:after {
background: #000;
}
<section>
<ul>
<li><a>Link 1</a></li>
<li><a>Link 2</a></li>
<li><a>Link 3</a></li>
<li><a>Link 4</a></li>
</ul>
</section>
I would just update the styles for your pseudo-elements on hover:
section ul {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: left;
list-style-type: none;
margin: .5em 1em;
}
li {
margin: 0;
border-radius: 1px;
position: relative;
padding: 0.3em 0.8em;
cursor: pointer;
}
li:hover a {
color: white;
}
li:nth-child(2n)::before {
content: "";
border-right: 2px solid black;
transform: rotate(-20deg);
display: block;
position: absolute;
top: -2px;
left: -5px;
width: 2px;
height: 120%;
}
li:nth-child(2n+1)::before {
content: "";
border-right: 2px solid black;
transform: rotate(20deg);
display: block;
position: absolute;
top: -2px;
left: -5px;
width: 2px;
height: 120%;
}
li:nth-child(2n):hover::before {
background-color: black;
top: -2px;
left: -6px;
width: calc(100% + 8px);
clip-path: polygon(0 0, 100% 0, 85% 100%, 15% 100%);
transform: none;
z-index: -1;
}
li:nth-child(2n+1):hover::before {
background-color: black;
top: -2px;
left: -6px;
width: calc(100% + 8px);
clip-path: polygon(15% 0, 85% 0, 100% 100%, 0 100%);
transform: none;
z-index: -1;
}
<section>
<ul>
<li><a>Link 1</a></li>
<li><a>Link 2</a></li>
<li><a>Link 3</a></li>
<li><a>Link 4</a></li>
</ul>
</section>
or you can try the way you wrote your codes.
used css shape:
section ul {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: left;
list-style-type: none;
margin: .5em 1em;
}
li {
margin: 0;
border-radius: 1px;
position: relative;
padding: 0.3em 0.8em;
cursor: pointer;
z-index:30;
}
li:nth-child(2n+1)::before {
content: "";
border-left: 2px solid red;
display: block;
position: absolute;
top: -2px;
left: -3px;
width: 100%;
height: 120%;
transform:skew(-20deg);
z-index:-1;
}
li:nth-child(2n+1)::after {
content: "";
position: absolute;
top: -2px;
left: -10px;
border-bottom: 41px solid rgba(255, 0, 0, 0.6);
border-left: 15px solid transparent;
border-right: 15px solid transparent;
height: 0;
width: 120%;
opacity:0;
z-index:-2;
transition:all 0.5s ease-in-out;
}
li:nth-child(2n)::before {
content: "";
border-right: 2px solid black;
transform: rotate(-20deg);
display: block;
position: absolute;
top: -2px;
left: -5px;
width: 2px;
height: 120%;
}
li:nth-child(2n)::after {
content: "";
position: absolute;
top: -2px;
left: -12px;
border-top: 40px solid rgba(0, 0, 0, 0.6);
border-left: 15px solid transparent;
border-right: 15px solid transparent;
height: 0;
width: 125%;
opacity:0;
z-index:-2;
transition:all 0.5s ease-in-out;
}
li:hover{
color: white!important;
}
li:hover::after {
opacity:1;
}

css progress bar with background color and border color

I need tab control like this
can any one please help me how to do.
I am able to create tab without background color like bellow:
#crumbs {
width: 100%;
display: grid;
}
#crumbs ul {
list-style: none;
padding: 7px 5px;
margin: 0px;
}
#crumbs ul li a {
display: block;
float: left;
height: 50px;
background: #3498db;
text-align: center;
padding: 30px 40px 0 80px;
position: relative;
margin: 0 10px 0 0;
font-size: 20px;
text-decoration: none;
color: #fff;
width: 22%;
}
#crumbs ul li a:after {
content: "";
border-top: 40px solid transparent;
border-bottom: 40px solid transparent;
border-left: 40px solid #3498db;
position: absolute;
right: -40px;
top: 0;
z-index: 1;
}
#crumbs ul li a:before {
content: "";
border-top: 40px solid transparent;
border-bottom: 40px solid transparent;
border-left: 40px solid #fff;
position: absolute;
left: 0;
top: 0;
}
#crumbs ul li a.inprogress {
display: block;
float: left;
height: 50px;
background: #34db3a;
text-align: center;
padding: 30px 40px 0 80px;
position: relative;
margin: 0 10px 0 0;
font-size: 20px;
text-decoration: none;
color: #fff;
width: 22%;
}
#crumbs ul li a.inprogress:after {
content: "";
border-top: 40px solid transparent;
border-bottom: 40px solid transparent;
border-left: 40px solid #34db3a;
position: absolute;
right: -40px;
top: 0;
z-index: 1;
}
#crumbs ul li a.inprogress:before {
content: "";
border-top: 40px solid transparent;
border-bottom: 40px solid transparent;
border-left: 40px solid #fff;
position: absolute;
left: 0;
top: 0;
}
#crumbs ul li a.cpmpleted {
display: block;
float: left;
height: 50px;
background: #b334db;
text-align: center;
padding: 30px 40px 0 80px;
position: relative;
margin: 0 10px 0 0;
font-size: 20px;
text-decoration: none;
color: #fff;
width: 22%;
}
#crumbs ul li a.cpmpleted:after {
content: "";
border-top: 40px solid transparent;
border-bottom: 40px solid transparent;
border-left: 40px solid #b334db;
position: absolute;
right: -40px;
top: 0;
z-index: 1;
}
#crumbs ul li a.cpmpleted:before {
content: "";
border-top: 40px solid transparent;
border-bottom: 40px solid transparent;
border-left: 40px solid #fff;
position: absolute;
left: 0;
top: 0;
}
<div id="crumbs">
<ul>
<li>One</li>
<li>Two</li>
<li> Three </li>
</ul>
</div>
I would consider skew transformation and pseudo element like this:
ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
padding: 0 20px;
}
li {
padding: 10px 30px;
position: relative;
}
li:before {
content: "";
z-index: -1;
position: absolute;
top: 0;
bottom: 50%;
right: 0;
left: 0;
background: var(--c);
transform: skew(40deg);
}
li:after {
content: "";
z-index: -1;
position: absolute;
top: 50%;
bottom: 0;
right: 0;
left: 0;
background: var(--c);
transform: skew(-40deg);
}
li.active:before {
border: 2px solid orange;
border-bottom: none;
}
li.active:after {
border: 2px solid orange;
border-top: none;
}
<ul>
<li style="--c:red"> Step 1</li>
<li style="--c:green" class="active"> Step 2</li>
<li style="--c:blue"> Step 3</li>
</ul>

Upside-down trapezoid navigation

I would like to make an upside down shape of a trapezoid, that I would like to use as a navigation bar.
Similar to this image:
You can try this
.nav>li>a, .nav>li>a:active, .nav>li>a:focus, .nav>li>a:hover {
display: inline-block!important;
position: relative!important;
color: #fff;
text-transform: uppercase;
margin-left: 60px;
box-shadow: 0px 4px 3px rgba(0,0,0,0.3);
padding: 0!important;
text-shadow:1px 1px 1px rgba(0,0,0,0.5);
}
.nav li a span {
display: inline-block;
position: relative;
padding: 15px 40px;
background: #ea9c0c;
}
.nav li a:after{
content:"";
width: 0;
height: 0;
border-top: 100px solid red;
border-right: 100px solid transparent;
}
.nav li a:after {
content: "";
width: 0;
height: 0;
border-top: 50px solid #ea9c0c;
border-right: 47px solid transparent;
position: absolute;
top: 0;
right: -47px;
z-index: 1;
}
.nav li a:before {
content: "";
width: 0;
height: 0;
border-top: 50px solid #ea9c0c;
border-left: 47px solid transparent;
position: absolute;
top: 0;
left: -47px;
z-index: 1;
}
.nav li a span:after {
content: "";
width: 0;
height: 0;
border-top: 50px solid rgba(0,0,0,0.3);
border-right: 47px solid transparent;
position: absolute;
top: 4px;
right: -47px;
}
.nav li a span:before {
content: "";
width: 0;
height: 0;
border-top: 50px solid rgba(0,0,0,0.3);
border-left: 47px solid transparent;
position: absolute;
top: 4px;
left: -47px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<ul class="nav">
<li><span>Home</span></li>
</ul>

Use pseudoclasses to create a CSS progress bar / stepper

I am building a stepper, trying to achieve this:
I've built the following, but the problem is the color overflows on the right side of the bar.
.onboarding-steps {
display: flex;
}
.onboarding-steps-container {
background-color: #393D66;
border-top: 1px solid #AEAEAE;
border-bottom: 1px solid #AEAEAE;
background-position: -50% 0;
}
.onboarding-step.active {
color: white;
}
.onboarding-step.active ~ .onboarding-step {
background-color: #fff;
}
.container-fluid {
max-width: 94px;
margin-right: auto;
margin-left: auto;
}
.list-reset {
list-style: none;
padding: 0;
margin: 0;
}
.onboarding-step {
-ms-flex-positive: 1;
flex-grow: 1;
padding: 1.8rem 1rem 1.8rem 1.5rem;
}
<nav class="onboarding-steps-container">
<div class="container-fluid">
<ul class="list-reset clearfix onboarding-steps">
<li class="onboarding-step">
1
</li>
<li class="onboarding-step active">
2
</li>
<li class="onboarding-step">
3
</li>
<li class="onboarding-step">
4
</li>
</ul>
</div>
</nav>
I have also tried a variation by using a pseudoselector as such:
li.onboarding-step.active:before {
background-color: #f9f9f9;
content: '';
left: 0;
right: 0;
top: 0;
bottom: 0;
height: 100%;
position: absolute;
}
.onboarding-steps-container {
position: relative;
}
in that case the color goes on the entire bar.
Here is an example.
.breadcrumb {
margin: 0;
padding: 0;
list-style: none;
overflow: hidden;
height: 36px;
display: flex;
justify-content: center;
align-items: center;
align-content: center;
padding-right: 35px;
}
.breadcrumb li {
text-decoration: none;
padding: 10px;
position: relative;
cursor: pointer;
flex: auto;
border: 1px solid red;
}
.breadcrumb li span {
font-size: 11px;
display: inline-block;
width: 16px;
line-height: 16px;
border-radius: 50%;
background-color: white;
vertical-align: middle;
text-align: center;
margin-left: calc(100% - 8px);
}
.breadcrumb li:after {
content: "";
display: block;
width: 0;
height: 0;
border-top: 50px solid transparent;
border-bottom: 50px solid transparent;
border-left: 30px solid #393D66;
position: absolute;
top: 50%;
margin-top: -50px;
left: 100%;
z-index: 2;
}
.breadcrumb li: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: 2px;
left: 100%;
z-index: 1;
}
li {
background-color: #393D66;
}
li:first-child {} li.active ~ li {
background-color: #f5f5f5;
}
li.active ~ li:after {
border-left-color: #f5f5f5;
}
li.active ~ li:before {
border-left-color: #d5d5d5;
}
li.active ~ li span {
background-color: #c5c5c5;
color: white;
}
<div class="stepper">
<ul class="breadcrumb">
<li><span>1</span>
</li>
<li><span>2</span>
</li>
<li class="active"><span>3</span>
</li>
<li><span>4</span>
</li>
<li><span>5</span>
</li>
</ul>
</div>
I'm not sure if you're looking for an answer which alters the <li> elements before and after the active <li> and the first <li> but here's a solution for that if you need one. Otherwise pretty much same stuff as Pugazh's answer.
html,
body {
background-color: #ccc;
}
.onboarding-steps {
list-style: none;
overflow: hidden;
font: 18px Helvetica, Arial, Sans-Serif;
}
.onboarding-steps li {
float: left;
}
.onboarding-steps li span {
color: white;
text-decoration: none;
padding: 10px 20px 10px 45px;
background: #393D66;
position: relative;
display: block;
float: left;
}
.onboarding-steps li span i {
display: block;
padding: 0 5px;
width: 5px;
height: 15px;
font-size: 10px;
background-color: white;
color: grey;
border-radius: 50%;
border: 1px solid grey;
}
.onboarding-steps li:first-child span {
padding: 10px 50px 10px 65px;
}
.onboarding-steps li.active ~ li span {
color: black;
background: #ffffff;
}
.onboarding-steps li span:after {
content: " ";
display: block;
width: 0;
height: 0;
border-top: 50px solid transparent;
border-bottom: 50px solid transparent;
border-left: 30px solid #393D66;
position: absolute;
top: 50%;
margin-top: -50px;
left: 100%;
z-index: 2;
}
.onboarding-steps li.active ~ li span:after {
border-left: 30px solid #ffffff;
}
.onboarding-steps li span: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;
}
.onboarding-steps li.active ~ li span:before {
border-left: 30px solid grey;
}
<ul class="onboarding-steps">
<li>
<span><i>1</i></span>
</li>
<li class="active">
<span><i>2</i></span>
</li>
<li>
<span><i>3</i></span>
</li>
<li>
<span><i>4</i></span>
</li>
</ul>
EDIT:
Here's another example. I even made the items clickable so that you can see how the background reacts with the <li> with active class.
var elements = document.querySelectorAll(".list-item");
for (var i = 0; i < elements.length; i++) {
elements[i].addEventListener("click", function() {
for (var i = 0; i < elements.length; i++) {
elements[i].classList.remove("active");
}
this.classList.add("active");
});
}
html,
body {
background-color: #ccc;
}
.onboarding-container {
background: #FFFFFF;
border: 2px solid black;
padding: 30px;
}
.onboarding-steps {
width: 100%;
max-width: 900px;
margin: 0 auto;
padding: 0;
list-style: none;
overflow: hidden;
font: 18px Helvetica, Arial, Sans-Serif;
display: flex;
}
.onboarding-steps li {
position: relative;
background: #393D66;
border-top: 1px solid grey;
border-bottom: 1px solid grey;
padding: 10px 30px 10px 40px;
flex: 1;
transition: flex 300ms linear 0s, background 100ms linear 0s;
}
.onboarding-steps li.active {
flex: 0 0 200px;
transition: flex 300ms linear 0s, background 100ms linear 0s;
}
.onboarding-steps li:first-child {
padding: 10px 30px 10px 10px;
}
.onboarding-steps li:last-child {
margin-right: -1px;
}
.onboarding-steps li span {
display: block;
padding: 0 5px;
width: 5px;
height: 15px;
font-size: 10px;
background-color: white;
color: grey;
border-radius: 50%;
border: 1px solid grey;
}
.onboarding-steps li:after {
content: " ";
display: block;
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-left: 20px solid #393D66;
position: absolute;
top: 50%;
margin-top: -20px;
left: 100%;
margin-left: -2px;
z-index: 2;
transition: border-left 100ms linear 0s;
}
.onboarding-steps li:before {
content: " ";
display: block;
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-left: 20px solid white;
position: absolute;
top: 50%;
margin-top: -20px;
margin-left: -1px;
left: 100%;
z-index: 1;
transition: border-left 100ms linear 0s;
}
.onboarding-steps li:last-child:after {
margin-left: -22px;
}
.onboarding-steps li:last-child:before {
margin-left: -21px;
border-top: 20px solid #ffffff;
border-bottom: 20px solid #ffffff;
}
.onboarding-steps li.active ~ li {
background: #ffffff;
}
.onboarding-steps li.active ~ li:after {
border-left: 20px solid #ffffff;
transition: border-left 100ms linear 0s;
}
.onboarding-steps li.active ~ li:before {
border-left: 20px solid grey;
transition: border-left 100ms linear 0s;
}
<div class="onboarding-container">
<ul class="onboarding-steps">
<li class="list-item active">
<span>1</span>
</li>
<li class="list-item">
<span>2</span>
</li>
<li class="list-item">
<span>3</span>
</li>
<li class="list-item">
<span>4</span>
</li>
</ul>
</div>
EDIT 2:
Based on your comment I made one more example and this is probably the closest you can get with just using CSS. Hopefully this will help you. Please do open it in fullscreen to see it working.
var elements = document.querySelectorAll(".list-item");
for (var i = 0; i < elements.length; i++) {
elements[i].addEventListener("click", function() {
for (var i = 0; i < elements.length; i++) {
elements[i].classList.remove("active");
}
this.classList.add("active");
});
}
html,
body {
background-color: #ccc;
}
* {
box-sizing: border-box;
}
.onboarding-container {
width: 100%;
background: #FFFFFF;
border: 2px solid black;
padding: 20px 0px;
}
.onboarding-container-inner {
position: relative;
width: 100%;
border-top: 1px solid grey;
border-bottom: 1px solid grey;
background: transparent;
z-index: 1;
overflow: hidden;
}
.onboarding-steps:before {
content: "";
display: inline-block;
width: 40%;
background: #393D66;
left: 0;
top: 0;
height: 100%;
position: absolute;
}
.onboarding-steps:after {
content: "";
display: inline-block;
width: 40%;
background: #ffffff;
right: 0;
top: 0;
height: 100%;
position: absolute;
z-index: -1;
}
.onboarding-steps {
width: 100%;
max-width: 600px;
margin: 0 auto;
padding: 0;
list-style: none;
font: 18px Helvetica, Arial, Sans-Serif;
display: flex;
}
.onboarding-steps li {
position: relative;
background: #393D66;
padding: 10px 30px 10px 40px;
flex: 1;
transition: flex 300ms linear 0s, background 100ms linear 0s;
}
.onboarding-steps li.active {
//flex: 0 0 200px;
transition: flex 300ms linear 0s, background 100ms linear 0s;
}
.onboarding-steps li:first-child {
padding: 10px 30px 10px 10px;
}
.onboarding-steps li:last-child {
margin-right: -1px;
}
.onboarding-steps li span {
display: block;
padding: 0 4px;
width: 15px;
height: 15px;
font-size: 10px;
background-color: white;
color: grey;
border-radius: 50%;
border: 1px solid grey;
}
.onboarding-steps li:after {
content: " ";
display: block;
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-left: 20px solid #393D66;
position: absolute;
top: 50%;
margin-top: -20px;
left: 100%;
margin-left: -2px;
z-index: 2;
transition: border-left 100ms linear 0s;
}
.onboarding-steps li:before {
content: " ";
display: block;
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-left: 20px solid white;
position: absolute;
top: 50%;
margin-top: -20px;
margin-left: -1px;
left: 100%;
z-index: 1;
transition: border-left 100ms linear 0s;
}
.onboarding-steps li:last-child:after {
margin-left: -22px;
}
.onboarding-steps li:last-child:before {
margin-left: -21px;
border-top: 20px solid #ffffff;
border-bottom: 20px solid #ffffff;
}
.onboarding-steps li.active:last-child:before {
border-top: 20px solid #393D66;
border-bottom: 20px solid #393D66;
}
.onboarding-steps li.active ~ li {
background: #ffffff;
}
.onboarding-steps li.active ~ li:after {
border-left: 20px solid #ffffff;
transition: border-left 100ms linear 0s;
}
.onboarding-steps li.active ~ li:before {
border-left: 20px solid grey;
transition: border-left 100ms linear 0s;
}
.onboarding-steps li.active:last-child:before {
content: "";
display: inline-block;
background: #393D66;
position: absolute;
right: 0;
top: 0;
width: 2500px;
height: 100%;
z-index: 1;
border-top: 0;
border-left: 0;
border-bottom: 0;
margin-top: 0;
transition: width 100ms linear 0s;
}
<div class="onboarding-container">
<div class="onboarding-container-inner">
<ul class="onboarding-steps">
<li class="list-item active">
<span>1</span>
</li>
<li class="list-item">
<span>2</span>
</li>
<li class="list-item">
<span>3</span>
</li>
<li class="list-item">
<span>4</span>
</li>
</ul>
</div>
</div>

Create the triangles in css

How this one can achieved in CSS. I googled out but i didn't find any solution.
Try this:
HTML
<nav class="nav">
<ul>
<li>1. Account Info</li>
<li>2. Verification</li>
<li>3. Enjoy</li>
</ul>
</nav>
StyleSheet
.nav ul {
margin: 0;
padding: 0;
list-style: none;
overflow: hidden;
width: 100%;
}
.nav ul li {
float: left;
margin: 0 .2em 0 1em;
}
.nav ul a {
background: red;
padding: .3em 1em;
float: left;
text-decoration: none;
color: #fff;
position: relative;
}
.nav ul li:first-child a:before {
content: normal;
}
.nav ul li:last-child a:after {
content: normal;
}
.nav ul a:before {
content: "";
position: absolute;
top: 50%;
margin-top: -1.5em;
border-width: 1.5em 0 1.5em 1em;
border-style: solid;
border-color: red rgba(0, 0, 0, 0);
left: -1em;
margin-left: 1px;
}
.nav ul a:after {
content: "";
position: absolute;
top: 50%;
margin-top: -1.5em;
border-top: 1.5em solid rgba(0, 0, 0, 0);
border-bottom: 1.5em solid rgba(0, 0, 0, 0);
border-left: 1em solid red;
right: -1em;
margin-right: 1px;
}
Here is the Demo
Try:
HTML:
<div class="arrow">
<p>1. Acount Info</p>
</div>
<div class="arrow2">
<p>2. Verification</p>
</div>
<div class="arrow3">
<p>3. Enjoy</p>
</div>
CSS:
.arrow {
width: 200px;
height: 33px;
background-color: red;
border: 1px solid red;
position: relative;
display:inline-block;
}
.arrow:after {
content:'';
position: absolute;
top: 0px;
left: 201px;
width: 0;
height: 0;
border: 17px solid transparent;
border-left: 12px solid red;
}
.arrow2 {
width: 200px;
height: 33px;
background-color: red;
border: 1px solid red;
position: relative;
display: inline-block;
margin-left: 8px;
}
.arrow2:after {
content:'';
position: absolute;
top: 0px;
left: 201px;
width: 0;
height: 0;
border: 17px solid transparent;
border-left: 12px solid red;
}
.arrow2:before {
content:'';
position: absolute;
top: 0px;
left: -1px;
width: 0;
height: 0;
border: 17px solid transparent;
border-left: 12px solid white;
}
.arrow3 {
width: 200px;
height: 33px;
background-color: red;
border: 1px solid red;
position: relative;
display: inline-block;
margin-left: 8px;
}
.arrow3:before {
content:'';
position: absolute;
top: 0px;
left: -1px;
width: 0;
height: 0;
border: 17px solid transparent;
border-left: 12px solid white;
}
p {
color:white;
text-align: center;
margin-top: 6px;
}
And the DEMO
Here's my attempt: http://codepen.io/anon/pen/xDeCd/
This example works well even if the user changes his font-size or triggers a page zoom. List-items should not break in several lines if the browser is resized.
Screenshot
Markup
<ol>
<li>1. Account info</li>
<li>2. Verification</li>
<li>3. Enjoy</li>
</ol>
(add links if/where necessary, I've just supposed they are not links but simply information labels about the required steps during a process).
Relevant CSS
ol {
white-space: nowrap;
}
li:after, li:before {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
position: absolute;
top: 0;
width: 1em;
height: 100%;
}
li {
display: inline-block;
position: relative;
height: 3em;
padding: 0 1em;
margin-right: 3em;
background: #d12420;
color: #f0f0f0;
font: 1em/3em Arial;
}
li + li { margin-left: -1.8em; }
li:not(:last-child):after {
left: 100%;
content: "";
border-left: 1em solid #d12420;
border-top: 1.5em solid transparent;
border-bottom: 1.5em solid transparent;
}
li + li:before {
content: "";
right: 100%;
border-left: 1em solid #transparent;
border-top: 1.5em solid #d12420;
border-bottom: 1.5em solid #d12420;
}
li:nth-child(1) { z-index: 3; }
li:nth-child(2) { z-index: 2; }
li:nth-child(3) { z-index: 1; }
Here is some code, it may be useful for youDEMO
<div class="breadcrumb flat">
<a class="active" href="#">1.Account Verification</a>
2.Verification
3.Enjoy
</div>