Responsive Progress Bar Vertical Alignment - html

I have a responsive multi step progress bar, link here and code snippet below;
.multi-steps > li.is-active:before, .multi-steps > li.is-active ~ li:before {
content: counter(stepNum);
font-family: inherit;
font-weight: 700;
}
.multi-steps > li.is-active:after, .multi-steps > li.is-active ~ li:after {
background-color: #ededed;
}
.multi-steps {
display: table;
table-layout: fixed;
width: 100%;
}
.multi-steps > li {
counter-increment: stepNum;
text-align: center;
display: table-cell;
position: relative;
color: tomato;
}
.multi-steps > li:before {
content: '\f00c';
content: '\2713;';
content: '\10003';
content: '\10004';
content: '\2713';
display: block;
margin: 0 auto 4px;
background-color: #fff;
width: 36px;
height: 36px;
line-height: 32px;
text-align: center;
font-weight: bold;
border-width: 2px;
border-style: solid;
border-color: tomato;
border-radius: 50%;
}
.multi-steps > li:after {
content: '';
height: 2px;
width: 100%;
background-color: tomato;
position: absolute;
top: 16px;
left: 50%;
z-index: -1;
}
.multi-steps > li:last-child:after {
display: none;
}
.multi-steps > li.is-active:before {
background-color: #fff;
border-color: tomato;
}
.multi-steps > li.is-active ~ li {
color: #808080;
}
.multi-steps > li.is-active ~ li:before {
background-color: #ededed;
border-color: #ededed;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<br /><br />
<ul class="list-unstyled multi-steps">
<li>Start</li>
<li class="is-active">First Step</li>
<li>Middle Stage</li>
<li>Finish</li>
</ul>
</div>
This works fine but on smaller screens (e.g max-device-width: 480px), portrait mode i'd like to stack the steps vertically.
How can I achieve this?

Inside your media query, change display: table-cell to display: block on the .multi-steps > li element. That should get you close to what you want to achieve. You'll also need to apply some additional styling just to neat it out. Hope that helps.
e.g.
.multi-steps > li {
display: block;
}

Add a <span> element arounf the text, the use this CSS
.multi-steps > li {
display: block;
position: relative;
padding-bottom: 45px;
}
.multi-steps > li:before {
content: '\f00c';
content: '\2713;';
content: '\10003';
content: '\10004';
content: '\2713';
display: block;
margin: 0 auto 4px;
background-color: #fff;
width: 36px;
height: 36px;
line-height: 32px;
text-align: center;
font-weight: bold;
border-width: 2px;
border-style: solid;
border-color: tomato;
border-radius: 50%;
}
.multi-steps > li:after {
content: '';
height: 2px;
width: 100%;
background-color: tomato;
position: absolute;
left: 50%;
z-index: -1;
display: inline-block;
top: 0;
left: 50%;
width: 3px;
height: 105px;
}
.multi-steps > li span.step {
margin-left: 50px;
position: relative;
top: 20px;
}

Related

Step progressbar

I'm trying to complete a step progress bar, and on the final node the complete color is not reaching to the end, the finalized color is not being applied:
#charset "UTF-8";
.container {
width: 100%;
}
.multi-steps > li.is-active ~ li:before, .multi-steps > li.is-active:before {
content: counter(stepNum);
font-family: inherit;
font-weight: 700;
}
.multi-steps > li.is-active ~ li:after, .multi-steps > li.is-active:after {
background-color: #ededed;
}
.multi-steps {
margin: 0;
border-top: 1px solid red;
display: flex;
padding: 0;
}
.multi-steps > li {
flex: 1;
position: relative;
text-align: center;
display: flex;
counter-increment: stepNum;
flex-direction: column;
align-items: flex-start;
color: tomato;
}
.multi-steps > li:before {
content: "ο€Œ";
content: "βœ“;";
content: "𐀃";
content: "𐀄";
content: "βœ“";
width: 36px;
height: 36px;
line-height: 32px;
display: block;
/*margin: 0 auto 4px;*/
background-color: #fff;
text-align: center;
font-weight: bold;
border-width: 2px;
border-style: solid;
border-color: tomato;
border-radius: 50%;
}
.multi-steps > li:after {
content: "";
position: absolute;
height: 2px;
width: 100%;
background-color: tomato;
top: 16px;
left: 0;
right: 0;
z-index: -1;
}
.multi-steps > li:last-child {
/*&:after{*/
flex-grow: 0;
align-items: flex-end;
white-space: nowrap;
/*display: none;*/
/*}*/
}
.multi-steps > li.is-active:before {
background-color: #fff;
border-color: tomato;
}
.multi-steps > li.is-active ~ li {
color: #808080;
}
.multi-steps > li.is-active ~ li:before {
background-color: #ededed;
border-color: #ededed;
}
<div class="container">
<br /><br />
<ul class="list-unstyled multi-steps">
<li>
<div>Start</div>
</li>
<li>
<div>Should be aligned center</div>
</li>
<li>
<div>Should be centered too</div>
</li>
<li class="is-active">
<div>Finish step belevie or not</div>
</li>
</ul>
</div>
on this code I should center the titles of bot nodes and also the "completed" color should reach until the last node. For more detail please refer to my sniped code with sass
The problem is in your line:
.multi-steps > li.is-active ~ li:after, .multi-steps > li.is-active:after {
background-color: #ededed;
}
Which overrides the colour. Simply removing this will add the colour back in:
#charset "UTF-8";
.container {
width: 100%;
}
.multi-steps > li.is-active ~ li:before, .multi-steps > li.is-active:before {
content: counter(stepNum);
font-family: inherit;
font-weight: 700;
}
.multi-steps {
margin: 0;
border-top: 1px solid red;
display: flex;
padding: 0;
}
.multi-steps > li {
flex: 1;
position: relative;
text-align: center;
display: flex;
counter-increment: stepNum;
flex-direction: column;
align-items: flex-start;
color: tomato;
}
.multi-steps > li:before {
content: "ο€Œ";
content: "βœ“;";
content: "𐀃";
content: "𐀄";
content: "βœ“";
width: 36px;
height: 36px;
line-height: 32px;
display: block;
/*margin: 0 auto 4px;*/
background-color: #fff;
text-align: center;
font-weight: bold;
border-width: 2px;
border-style: solid;
border-color: tomato;
border-radius: 50%;
}
.multi-steps > li:after {
content: "";
position: absolute;
height: 2px;
width: 100%;
background-color: tomato;
top: 16px;
left: 0;
right: 0;
z-index: -1;
}
.multi-steps > li:last-child {
/*&:after{*/
flex-grow: 0;
align-items: flex-end;
white-space: nowrap;
/*display: none;*/
/*}*/
}
.multi-steps > li.is-active:before {
background-color: #fff;
border-color: tomato;
}
.multi-steps > li.is-active ~ li {
color: #808080;
}
.multi-steps > li.is-active ~ li:before {
background-color: #ededed;
border-color: #ededed;
}
<div class="container">
<br /><br />
<ul class="list-unstyled multi-steps">
<li>
<div>Start</div>
</li>
<li>
<div>Should be aligned center</div>
</li>
<li>
<div>Should be centered too</div>
</li>
<li class="is-active">
<div>Finish step belevie or not</div>
</li>
</ul>
</div>

Drawing a tick mark in the progressbar if the process is done

I was created a simple progressbar with CSS & HTML. Here I used three classes active, inactive & done.
.container {
width: 600px;
margin: 100px auto;
}
.progressbar li {
list-style-type: none;
width: 25%;
float: left;
font-size: 12px;
position: relative;
text-align: center;
color: #7d7d7d;
}
.progressbar li:before {
width: 30px;
height: 30px;
content: "";
line-height: 30px;
border: 2px solid #7d7d7d;
display: block;
text-align: center;
margin: 0 auto 10px auto;
border-radius: 50%;
background-color: white;
}
.progressbar li:after {
width: 100%;
height: 2px;
content: '';
position: absolute;
background-color: #7d7d7d;
top: 15px;
left: -50%;
z-index: -1;
}
.progressbar li:first-child:after {
content: none;
}
.progressbar li.active {
color: green;
}
.progressbar li.active:before {
border-color: #55b776;
background-color: #55b776;
}
.progressbar li.active+li:after {
background-color: #55b776;
}
.progressbar li.done:before {
border-color: #55b776;
background-color: #55b776;
}
.progressbar li.done+li:after {
background-color: #55b776;
}
.progressbar li.inactive:before {
border-color: #7d7d7d;
background-color: #7d7d7d;
}
.progressbar li.inactive+li:after {
background-color: #7d7d7d;
}
<div class="container">
<ul class="progressbar">
<li class="done"></li>
<li class="active"></li>
<li class="inactive"></li>
</ul>
</div>
If the class is active it will show the circle with background-color: green,
If the class is inactive it will show the circle with background-color: grey
What i want is while using class 'done' i need to show the circle with background-color: green and tick mark inside the green circle like this. I tried a lot but not able to finish it. Please someone help me. Here is my working fiddle link
Use tick mark in content: "βœ“";
.container {
width: 600px;
margin: 100px auto;
}
.progressbar li {
list-style-type: none;
width: 25%;
float: left;
font-size: 12px;
position: relative;
text-align: center;
color: #7d7d7d;
}
.progressbar li:before {
width: 30px;
height: 30px;
content: "";
line-height: 30px;
border: 2px solid #7d7d7d;
display: block;
text-align: center;
margin: 0 auto 10px auto;
border-radius: 50%;
background-color: white;
}
.progressbar li.done:before {
content: "βœ“";
color: #ffffff;
font-size: 20px;
}
.progressbar li:after {
width: 100%;
height: 2px;
content: '';
position: absolute;
background-color: #7d7d7d;
top: 15px;
left: -50%;
z-index: -1;
}
.progressbar li:first-child:after {
content: none;
}
.progressbar li.active {
color: green;
}
.progressbar li.active:before {
border-color: #55b776;
background-color: #55b776;
}
.progressbar li.active + li:after {
background-color: #55b776;
}
.progressbar li.done:before {
border-color: #55b776;
background-color: #55b776;
}
.progressbar li.done + li:after {
background-color: #55b776;
}
.progressbar li.inactive:before {
border-color: #7d7d7d;
background-color: #7d7d7d;
}
.progressbar li.inactive + li:after {
background-color: #7d7d7d;
}
<div class="container">
<ul class="progressbar">
<li class="done"></li>
<li class="active"></li>
<li class="inactive"></li>
</ul>
</div>
As per your Requirements using css
.container {
width: 600px;
margin: 100px auto;
}
.progressbar li {
list-style-type: none;
width: 25%;
float: left;
font-size: 12px;
position: relative;
text-align: center;
color: #7d7d7d;
}
.progressbar li:before {
width: 30px;
height: 30px;
content: "";
line-height: 30px;
border: 2px solid #7d7d7d;
display: block;
text-align: center;
margin: 0 auto 10px auto;
border-radius: 50%;
background-color: white;
}
.progressbar li:after {
width: 100%;
height: 2px;
content: '';
position: absolute;
background-color: #7d7d7d;
top: 15px;
left: -50%;
z-index: -1;
}
.progressbar li:first-child:after {
content: none;
}
.progressbar li.active {
color: green;
}
.progressbar li.active:before {
border-color: #55b776;
background-color: #55b776;
}
.progressbar li.active + li:after {
background-color: #55b776;
}
.progressbar li.done:before {
border-color: #55b776;
background-color: #55b776;
}
.progressbar li.done + li:after {
background-color: #55b776;
}
.progressbar li.inactive:before {
border-color: #7d7d7d;
background-color: #7d7d7d;
}
.progressbar li.inactive + li:after {
background-color: #7d7d7d;
}
.progressbar li.done {
font-size: 16px;
position: relative;
}
.progressbar li.done:after {
content: " ";
display: block;
width: 0.3em;
height: 0.6em;
border: solid white;
border-width: 0 0.2em 0.2em 0;
position: absolute;
left: 4.2em;
top: 26%;
margin-top: -0.2em;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
z-index:9;
background-color: #55b776;
}
<div class="container">
<ul class="progressbar">
<li class="done"></li>
<li class="active"></li>
<li class="inactive"></li>
</ul>
</div>
You only need to set the content to the tick mark when the done class is applied.
.progressbar li.done:before {
content: "βœ”";
}
Wirking fiddle: https://jsfiddle.net/ordmpf59/

Stepper Pure HTML CSS

I'm confused about a progress bar that I have created.
I want the progress bar to change its background color to blue after setting the class to β€œactive”. But I want the progress bar to change its background color before the class is set to β€œactive”.
Here is my HTML:
<ul class="progressBar">
<li class="active">Beong Processed</li>
<li class="active">Waiting for payment</li>
<li>Paid</li>
</ul>
…and CSS:
.progressBar li.active {
color: dodgerblue;
}
.progressBar li.active:before {
border-color: dodgerblue;
background-color: dodgerblue
}
.progressBar li.active + li:after {
background-color: dodgerblue;
}
The result is this
I want it to be like this
https://jsfiddle.net/dedi_wibisono17/c69e374r/2/
Use .progressBar .active:after
instead of .progressBar li.active + li:after
+ in css
It is Adjacent sibling combinator. It combines two sequences of simple
selectors having the same parent and the second one must come
IMMEDIATELY after the first.
.wrapper-progressBar {
width: 100%
}
.progressBar {
}
.progressBar li {
list-style-type: none;
float: left;
width: 33%;
position: relative;
text-align: center;
}
.progressBar li:before {
content: " ";
line-height: 30px;
border-radius: 50%;
width: 30px;
height: 30px;
border: 1px solid #ddd;
display: block;
text-align: center;
margin: 0 auto 10px;
background-color: white
}
.progressBar li:after {
content: "";
position: absolute;
width: 100%;
height: 4px;
background-color: #ddd;
top: 15px;
left: -50%;
z-index: -1;
}
.progressBar li:first-child:after {
content: none;
}
.progressBar li.active {
color: dodgerblue;
}
.progressBar li.active:before {
border-color: dodgerblue;
background-color: dodgerblue
}
.progressBar .active:after {
background-color: dodgerblue;
}
<div class="row">
<div class="col-xs-12 col-md-8 offset-md-2 block border">
<div class="wrapper-progressBar">
<ul class="progressBar">
<li class="active">Beong Processed</li>
<li class="active">Waiting for payment</li>
<li>Paid</li>
</ul>
</div>
</div>
</div>
According to what you requested, this is more like the answer you asked for?
.wrapper-progressBar {
width: 100%
}
.progressBar {
}
.progressBar li {
list-style-type: none;
float: left;
width: 33%;
position: relative;
text-align: center;
}
.progressBar li:before {
content: " ";
line-height: 30px;
border-radius: 50%;
width: 17px;
height: 17px;
border: 1px solid #ddd;
border-left:none;
display: block;
text-align: center;
margin: 8.5px auto 0px;
background-color: #eee;
}
.progressBar li:after {
content: "";
position: absolute;
width: 97%;
height: 5px;
background-color: #eee;
border: 1px solid #ddd;
border-right:none;
top: 15px;
left: -50%;
z-index: -1;
}
.progressBar li:first-child:after {
content: none;
}
.progressBar li.active {
color: dodgerblue;
}
.progressBar li.active:before {
border-color: dodgerblue;
background-color: dodgerblue
}
.progressBar .active:after {
background-color: dodgerblue;
}
<div class="row">
<div class="col-xs-12 col-md-8 offset-md-2 block border">
<div class="wrapper-progressBar">
<ul class="progressBar">
<li class="active">Beong Processed</li>
<li class="active">Waiting for payment</li>
<li>Paid</li>
</ul>
</div>
</div>
</div>
Try changing your .progressBar li.active + li:after selector to .progressBar li.active:after
.wrapper-progressBar {
width: 100%
}
.progressBar {
}
.progressBar li {
list-style-type: none;
float: left;
width: 33%;
position: relative;
text-align: center;
}
.progressBar li:before {
content: " ";
line-height: 30px;
border-radius: 50%;
width: 30px;
height: 30px;
border: 1px solid #ddd;
display: block;
text-align: center;
margin: 0 auto 10px;
background-color: white
}
.progressBar li:after {
content: "";
position: absolute;
width: 100%;
height: 2px;
background-color: #ddd;
top: 15px;
left: -50%;
z-index: -1;
}
.progressBar li:first-child:after {
content: none;
}
.progressBar li.active {
color: dodgerblue;
}
.progressBar li.active:before {
border-color: dodgerblue;
background-color: dodgerblue
}
.progressBar li.active:after {
background-color: dodgerblue;
}
<div class="row">
<div class="col-xs-12 col-md-8 offset-md-2 block border">
<div class="wrapper-progressBar">
<ul class="progressBar">
<li class="active">Beong Processed</li>
<li class="active">Waiting for payment</li>
<li>Paid</li>
</ul>
</div>
</div>
</div>

css step wizard z-index not working

I've coded the step wizard as below.
ul.progress[data-steps="2"] li { width: 49%; }
ul.progress[data-steps="3"] li { width: 33%; }
ul.progress[data-steps="4"] li { width: 24%; }
ul.progress[data-steps="5"] li { width: 19%; }
ul.progress[data-steps="6"] li { width: 16%; }
ul.progress[data-steps="7"] li { width: 14%; }
ul.progress[data-steps="8"] li { width: 12%; }
ul.progress[data-steps="9"] li { width: 11%; }
.progress {
width: 100%;
list-style: none;
list-style-image: none;
padding: 20px 0;
margin:0;
overflow:hidden;
border:2px solid #000;
}
.progress li {
float: left;
text-align: center;
position: relative;
}
.progress .name {
display: block;
vertical-align: bottom;
text-align: center;
margin-bottom: 25px;
color: black;
opacity: 0.3;
}
.progress .step {
color: black;
border: 3px solid silver;
background-color: silver;
border-radius: 50%;
line-height: 1.2;
width: 30px;
height: 30px;
display: inline-block;
z-index: 10;
}
.progress .step span {
opacity: 0.3;
}
.progress .active .name,
.progress .active .step span {
}
.progress .step:before {
content: "";
display: block;
background-color: silver;
height: 5px;
width: 50%;
position: absolute;
bottom: 15px;
left: 0;
z-index: 9;
}
.progress .step:after {
content: "";
display: block;
background-color: silver;
height: 5px;
width: 50%;
position: absolute;
bottom: 15px;
right: 0;
z-index: 9;
}
.progress li:first-of-type .step:before {
display: none;
}
.progress li:last-of-type .step:after {
display: none;
}
.progress .done .step,
.progress .done .step:before,
.progress .done .step:after,
.progress .active .step,
.progress .active .step:before {
background-color: yellowgreen;
}
.progress .done .step,
.progress .active .step {
border: 3px solid yellowgreen;
}
<div>
<ul class="progress" data-steps="4">
<li class="done">
<span class="name">Foo</span>
<span class="step"><span>1</span></span>
</li>
<li class="done">
<span class="name">Bar</span>
<span class="step"><span>2</span></span>
</li>
<li class="active">
<span class="name">Baz</span>
<span class="step"><span>3</span></span>
</li>
<li>
<span class="name">Quux</span>
<span class="step"><span>4</span></span>
</li>
</ul>
</div>
But the z-index doesn't work.
z-index of the class "step" is 10, while the one of "step:before,step:after" is 9.
Why does the "step:after" element , gray line , put above the green circle?
So I don't understand the z-index well.
Thanks.
Please try this one.
1. I've added the z-index in .active .step span and and made it to circle with background.
.progress .active .name,
.progress .active .step span {
position:relative;
z-index:11;
opacity: 1;
}
.progress .active .step span {
border-radius: 50%;
line-height: 1.2;
width: 35px;
height: 29px;
display: inline-block;
z-index: 12;
margin:-2px 0 0 -2px;
padding-top:6px;
background-color: yellowgreen;
}
I've added the lower z-index in .active .step:after than .step.
.progress .active .step:after {
z-index:8;
}
Please see whole code below;
ul.progress[data-steps="2"] li { width: 49%; }
ul.progress[data-steps="3"] li { width: 33%; }
ul.progress[data-steps="4"] li { width: 24%; }
ul.progress[data-steps="5"] li { width: 19%; }
ul.progress[data-steps="6"] li { width: 16%; }
ul.progress[data-steps="7"] li { width: 14%; }
ul.progress[data-steps="8"] li { width: 12%; }
ul.progress[data-steps="9"] li { width: 11%; }
.progress {
width: 100%;
list-style: none;
list-style-image: none;
padding: 20px 0;
margin:0;
overflow:hidden;
border:2px solid #000;
}
.progress li {
float: left;
text-align: center;
position: relative;
}
.progress .name {
display: block;
vertical-align: bottom;
text-align: center;
margin-bottom: 25px;
color: black;
opacity: 0.3;
}
.progress .step {
color: black;
border: 3px solid silver;
background-color: silver;
border-radius: 50%;
line-height: 1.2;
width: 30px;
height: 30px;
display: inline-block;
z-index: 10;
}
.progress .step span {
opacity: 0.3;
display:inline-block;
margin-top:4px;
position:relative;
z-index:10;
}
.progress .active .step span {
border-radius: 50%;
line-height: 1.2;
width: 35px;
height: 29px;
display: inline-block;
z-index: 12;
margin:-2px 0 0 -2px;
padding-top:6px;
background-color: yellowgreen;
}
.progress .active .name,
.progress .active .step span {
position:relative;
z-index:11;
opacity: 1;
}
.progress .step:before {
content: "";
display: block;
background-color: silver;
height: 5px;
width: 50%;
position: absolute;
bottom: 15px;
left: 0;
z-index: 9;
}
.progress .step:after {
content: "";
display: block;
background-color: silver;
height: 5px;
width: 50%;
position: absolute;
bottom: 15px;
right: 0;
z-index: 9;
}
.progress li:first-of-type .step:before {
display: none;
}
.progress li:last-of-type .step:after {
display: none;
}
.progress .done .step,
.progress .done .step:before,
.progress .done .step:after,
.progress .active .step,
.progress .active .step:before {
background-color: yellowgreen;
}
.progress .active .step:after {
z-index:8;
}
.progress .done .step,
.progress .active .step {
border: 3px solid yellowgreen;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div>
<ul class="progress" data-steps="4">
<li class="done">
<span class="name">Foo</span>
<span class="step"><span>1</span></span>
</li>
<li class="done">
<span class="name">Bar</span>
<span class="step"><span>2</span></span>
</li>
<li class="active">
<span class="name">Baz</span>
<span class="step"><span>3</span></span>
</li>
<li>
<span class="name">Quux</span>
<span class="step"><span>4</span></span>
</li>
</ul>
</div>
</body>
</html>
I am able to achieve the result by not given the .step class a z-index and then giving the :before and :after element a negative z-index.
I believe that giving the .step class a z-index value affects its :before and :after elements. For more details on that please see Michael Coker's great technical explanation in the comments below.
If there are other elements on the page like a background, give the background a z-index value of -2 like I did with the body
body {
background:rgba(0, 0, 0, 0.77);
z-index:-2;
}
ul.progress[data-steps="2"] li { width: 49%; }
ul.progress[data-steps="3"] li { width: 33%; }
ul.progress[data-steps="4"] li { width: 24%; }
ul.progress[data-steps="5"] li { width: 19%; }
ul.progress[data-steps="6"] li { width: 16%; }
ul.progress[data-steps="7"] li { width: 14%; }
ul.progress[data-steps="8"] li { width: 12%; }
ul.progress[data-steps="9"] li { width: 11%; }
.progress {
width: 100%;
list-style: none;
list-style-image: none;
padding: 20px 0;
margin:0;
overflow:hidden;
border:2px solid #000;
}
.progress li {
float: left;
text-align: center;
position: relative;
}
.progress .name {
display: block;
vertical-align: bottom;
text-align: center;
margin-bottom: 25px;
color: white;
opacity: 1;
}
.progress .step {
color: black;
border: 3px solid silver;
background-color: silver;
border-radius: 50%;
line-height: 1.2;
width: 30px;
height: 30px;
display: inline-block;
}
.progress .step span {
opacity: 1;
}
.progress .active .name,
.progress .active .step span {
}
.progress .step:before {
content: "";
display: block;
background-color: silver;
height: 5px;
width: 50%;
position: absolute;
bottom: 15px;
left: 0;
z-index: -1;
}
.progress .step:after {
content: "";
display: block;
background-color: silver;
height: 5px;
width: 50%;
position: absolute;
bottom: 15px;
right: 0;
z-index: -1;
}
.progress li:first-of-type .step:before {
display: none;
}
.progress li:last-of-type .step:after {
display: none;
}
.progress .done .step,
.progress .done .step:before,
.progress .done .step:after,
.progress .active .step,
.progress .active .step:before {
background-color: yellowgreen;
}
.progress .done .step,
.progress .active .step {
border: 3px solid yellowgreen;
}
<div>
<ul class="progress" data-steps="4">
<li class="done">
<span class="name">Foo</span>
<span class="step"><span>1</span></span>
</li>
<li class="done">
<span class="name">Bar</span>
<span class="step"><span>2</span></span>
</li>
<li class="active">
<span class="name">Baz</span>
<span class="step"><span>3</span></span>
</li>
<li>
<span class="name">Quux</span>
<span class="step"><span>4</span></span>
</li>
</ul>
</div>
Please try to set z-index of before and after element to -1.

Show progress half way in li using css

Something like below:
My Less looks as below at the moment.
/*progressbar*/
.progressbar {
margin-bottom: 30px;
margin-top: 10px;
counter-reset: step;
clear: both;
}
.progressbar li {
font-size: 12px;
width: 24%;
float: left;
position: relative;
text-align: center;
&:before {
content: counter(step);
counter-increment: step;
width: 25px;
line-height: 13px;
display: block;
font-size: 12px;
color: transparent;
border: 6px solid #ececec ;
background: #27ae60 ;
border-radius: 19px;
margin: 0 auto 4px;
}
&:after {
content: '';
width: 85%;
height: 3px;
background: #B9B9B9;
position: absolute;
left: -42%;
top: 10px;
z-index: 0;
}
&:first-child:after {
content: none;
}
}
.progress-payment li {
width: 50%;
}
.progressbar li.active{
&:after, &:before {
background: #success-btn;
color: #success-btn;
}
}
HTML
<ul class="progressbar">
<li class="active">Order Placed</li>
<li>Shipped</li>
<li>Completed</li>
<li>Settled</li>
</ul>
Please help
You can do this by using a linear-gradient background for the pseudo element that is producing the bar. The gradient is half-and-half, with completed color for first half and the pending color for rest.
/*progressbar*/
.progressbar {
margin-bottom: 30px;
margin-top: 10px;
counter-reset: step;
clear: both;
list-style: none;
}
.progressbar li {
font-size: 12px;
width: 24%;
float: left;
position: relative;
text-align: center;
}
.progressbar li:before {
content: counter(step);
counter-increment: step;
width: 25px;
line-height: 25px;
display: block;
font-size: 12px;
color: transparent;
border: 6px solid #ececec;
background: #27ae60;
border-radius: 19px;
margin: 0 auto 4px;
}
.progressbar li:after {
content: '';
width: 85%;
height: 3px;
background: #B9B9B9;
position: absolute;
left: -42%;
top: 17px;
z-index: -1;
}
.progressbar li:first-child:after {
content: none;
}
.progress-payment li {
width: 50%;
}
.progressbar li.active:after,
.progressbar li.active:before {
background: #27ae60;
color: white;
}
.progressbar li.complete:after {
background: #27ae60;
}
.progressbar li.half-complete:after {
background: linear-gradient(to right, #27ae60 50%, #B9B9B9 50%);
color: white;
}
<ul class="progressbar">
<li class="complete">Order Placed</li>
<li class="complete">Shipped</li>
<li class="active">Completed</li>
<li class="half-complete">Settled</li>
</ul>
If you want a slightly curved half-fill for the progress bar then you could use radial-gradient for the background like in the below snippet.
/*progressbar*/
.progressbar {
margin-bottom: 30px;
margin-top: 10px;
counter-reset: step;
clear: both;
list-style: none;
}
.progressbar li {
font-size: 12px;
width: 24%;
float: left;
position: relative;
text-align: center;
}
.progressbar li:before {
content: counter(step);
counter-increment: step;
width: 25px;
line-height: 25px;
display: block;
font-size: 12px;
color: transparent;
border: 6px solid #ececec;
background: #27ae60;
border-radius: 19px;
margin: 0 auto 4px;
}
.progressbar li:after {
content: '';
width: 85%;
height: 3px;
background: #B9B9B9;
position: absolute;
left: -42%;
top: 17px;
z-index: -1;
}
.progressbar li:first-child:after {
content: none;
}
.progress-payment li {
width: 50%;
}
.progressbar li.active:after,
.progressbar li.active:before {
background: #27ae60;
color: white;
}
.progressbar li.complete:after {
background: #27ae60;
}
.progressbar li.half-complete:after {
background: radial-gradient(50% 300% at 25% 50%, #27ae60 50%, #B9B9B9 40%);
color: white;
}
<ul class="progressbar">
<li class="complete">Order Placed</li>
<li class="complete">Shipped</li>
<li class="active">Completed</li>
<li class="half-complete">Settled</li>
</ul>
Note: Both the solutions assume that your target browsers are those that support gradients (IE10+).
Another approach is to use animation for this.
Since you are already using both pseudoelements in your list items. We will use a pseudoelement in the ul element to provide the empty progress line.
We will keep your other classes just for demo purposes but you can optimize this method way further. The principle would have to change to take into consideration the whole process from 0 to 100% from step 1 to 4, not to 1 to 2, 2 to 3, etc.
Here we go:
First we create our pseudoelement in the ul element just for the grey fallback.
.progressbar::after {
content: '';
width: 68%;
height: 3px;
background: #B9B9B9;
position: absolute;
left: 17%;
top: 17px;
z-index: -2;
}
Then we scale down the ::after pseudoelement of the list item to 0 in the main axis. (use one : if you are providing older browser support).
Here we are keeping your class just as a selector, like I previously said you can make this even better but it would require changing some logic.
Here we also declare an animation we will create in the next step. What will it do? It will just scale back to 1 our pseudoelement.
.progressbar li.half-complete:after {
transform: scaleX(0);
color: white;
animation: fill 100ms linear forwards;
background-color: #27ae60;
}
We define the keyframe:
#keyframes fill {
to {
transform: scaleX(1);
}
}
So far we get this:
/*progressbar*/
.progressbar {
margin-bottom: 30px;
margin-top: 10px;
counter-reset: step;
clear: both;
list-style: none;
position: relative;
}
.progressbar li {
font-size: 12px;
width: 24%;
float: left;
position: relative;
text-align: center;
}
.progressbar li:before {
content: counter(step);
counter-increment: step;
width: 25px;
line-height: 25px;
display: block;
font-size: 12px;
color: transparent;
border: 6px solid #ececec;
background: #27ae60;
border-radius: 19px;
margin: 0 auto 4px;
}
.progressbar li:after {
content: '';
width: 85%;
height: 3px;
position: absolute;
left: -42%;
top: 17px;
z-index: -1;
}
.progressbar::after {
content: '';
width: 68%;
height: 3px;
background: #B9B9B9;
position: absolute;
left: 17%;
top: 17px;
z-index: -2;
}
.progressbar li:first-child:after {
content: none;
}
.progress-payment li {
width: 50%;
}
.progressbar li.active:after,
.progressbar li.active:before {
background: #27ae60;
color: white;
}
.progressbar li.half-complete:before {
color: white;
}
.progressbar li.complete:after {
background: #27ae60;
}
.progressbar li.half-complete:after {
transform: scaleX(0);
color: white;
animation: fill 3s linear forwards;
background-color: #27ae60;
}
#keyframes fill {
to {
transform: scaleX(1);
}
}
<ul class="progressbar">
<li class="complete">Order Placed</li>
<li class="complete">Shipped</li>
<li class="active">Completed</li>
<li class="half-complete">Settled</li>
</ul>
We are not quite there yet, we got the animation, but it starts from the center and we want a specific frame, when the bar is at 50%.
Since the browser creates multiple frames when you create an animation, you can get the one you want with the property animation-delay, normally you would use a positive value, but when you use a negative one, the animation starts from that point.
Lets make the animation start from the left with transform-origin: left and finish all the way to the right without using animation-delay yet:
/*progressbar*/
.progressbar {
margin-bottom: 30px;
margin-top: 10px;
counter-reset: step;
clear: both;
list-style: none;
position: relative;
}
.progressbar li {
font-size: 12px;
width: 24%;
float: left;
position: relative;
text-align: center;
}
.progressbar li:before {
content: counter(step);
counter-increment: step;
width: 25px;
line-height: 25px;
display: block;
font-size: 12px;
color: transparent;
border: 6px solid #ececec;
background: #27ae60;
border-radius: 19px;
margin: 0 auto 4px;
}
.progressbar li:after {
content: '';
width: 85%;
height: 3px;
position: absolute;
left: -42%;
top: 17px;
z-index: -1;
}
.progressbar::after {
content: '';
width: 68%;
height: 3px;
background: #B9B9B9;
position: absolute;
left: 17%;
top: 17px;
z-index: -2;
}
.progressbar li:first-child:after {
content: none;
}
.progress-payment li {
width: 50%;
}
.progressbar li.active:after,
.progressbar li.active:before {
background: #27ae60;
color: white;
}
.progressbar li.half-complete:before {
color: white;
}
.progressbar li.complete:after {
background: #27ae60;
}
.progressbar li.half-complete:after {
transform: scaleX(0);
color: white;
animation: fill 3s linear forwards;
transform-origin: left;
background-color: #27ae60;
}
#keyframes fill {
to {
transform: scaleX(1);
}
}
<ul class="progressbar">
<li class="complete">Order Placed</li>
<li class="complete">Shipped</li>
<li class="active">Completed</li>
<li class="half-complete">Settled</li>
</ul>
Now using an animation-delay with a negative value:
/*progressbar*/
.progressbar {
margin-bottom: 30px;
margin-top: 10px;
counter-reset: step;
clear: both;
list-style: none;
position: relative;
}
.progressbar li {
font-size: 12px;
width: 24%;
float: left;
position: relative;
text-align: center;
}
.progressbar li:before {
content: counter(step);
counter-increment: step;
width: 25px;
line-height: 25px;
display: block;
font-size: 12px;
color: transparent;
border: 6px solid #ececec;
background: #27ae60;
border-radius: 19px;
margin: 0 auto 4px;
}
.progressbar li:after {
content: '';
width: 85%;
height: 3px;
position: absolute;
left: -42%;
top: 17px;
z-index: -1;
}
.progressbar::after {
content: '';
width: 68%;
height: 3px;
background: #B9B9B9;
position: absolute;
left: 17%;
top: 17px;
z-index: -2;
}
.progressbar li:first-child:after {
content: none;
}
.progress-payment li {
width: 50%;
}
.progressbar li.active:after,
.progressbar li.active:before {
background: #27ae60;
color: white;
}
.progressbar li.half-complete:before {
color: white;
}
.progressbar li.complete:after {
background: #27ae60;
}
.progressbar li.half-complete:after {
transform: scaleX(0);
color: white;
animation: fill 3s linear forwards;
transform-origin: left;
animation-delay: -1.5s;
background-color: #27ae60;
}
#keyframes fill {
to {
transform: scaleX(1);
}
}
<ul class="progressbar">
<li class="complete">Order Placed</li>
<li class="complete">Shipped</li>
<li class="active">Completed</li>
<li class="half-complete">Settled</li>
</ul>
Since the total duration of the animation in the demo is 3s you just use half that as a negative value to get the 50%, see how the animation starts from there.
Then we just use animation-play-state: paused; to prevent the transition.
/*progressbar*/
.progressbar {
margin-bottom: 30px;
margin-top: 10px;
counter-reset: step;
clear: both;
list-style: none;
position: relative;
}
.progressbar li {
font-size: 12px;
width: 24%;
float: left;
position: relative;
text-align: center;
}
.progressbar li:before {
content: counter(step);
counter-increment: step;
width: 25px;
line-height: 25px;
display: block;
font-size: 12px;
color: transparent;
border: 6px solid #ececec;
background: #27ae60;
border-radius: 19px;
margin: 0 auto 4px;
}
.progressbar li:after {
content: '';
width: 85%;
height: 3px;
position: absolute;
left: -42%;
top: 17px;
z-index: -1;
}
.progressbar::after {
content: '';
width: 68%;
height: 3px;
background: #B9B9B9;
position: absolute;
left: 17%;
top: 17px;
z-index: -2;
}
.progressbar li:first-child:after {
content: none;
}
.progress-payment li {
width: 50%;
}
.progressbar li.active:after,
.progressbar li.active:before {
background: #27ae60;
color: white;
}
.progressbar li.half-complete:before {
color: white;
}
.progressbar li.complete:after {
background: #27ae60;
}
.progressbar li.half-complete:after {
transform: scaleX(0);
color: white;
animation: fill 3s linear forwards;
transform-origin: left;
animation-delay: -1.5s;
animation-play-state: paused;
background-color: #27ae60;
}
#keyframes fill {
to {
transform: scaleX(1);
}
}
<ul class="progressbar">
<li class="complete">Order Placed</li>
<li class="complete">Shipped</li>
<li class="active">Completed</li>
<li class="half-complete">Settled</li>
</ul>
We can then clean it a little bit and in this demo we use some javascript to see how this can be manipulated:
.progressbar li.half-complete:after {
transform: scaleX(0);
color: white;
animation: fill 100ms linear forwards; /* Use an easier value to represent percentages in a progress bar*/
transform-origin: left;
animation-delay: inherit; /* We inherit the animation-delay from the `li` element, which we can easily manipulate with javascript*/
animation-play-state: paused;
background-color: #27ae60;
}
Final Result:
var progress = document.getElementById("progress");
var progressBarLastItem = document.querySelector(".progressbar li:last-child");
progress.addEventListener("change", function() {
progressBarLastItem.style.animationDelay = "-" + this.value + "ms";
});
/*progressbar*/
.progressbar {
margin-bottom: 30px;
margin-top: 10px;
counter-reset: step;
clear: both;
list-style: none;
position: relative;
}
.progressbar li {
font-size: 12px;
width: 24%;
float: left;
position: relative;
text-align: center;
}
.progressbar li:before {
content: counter(step);
counter-increment: step;
width: 25px;
line-height: 25px;
display: block;
font-size: 12px;
color: transparent;
border: 6px solid #ececec;
background: #27ae60;
border-radius: 19px;
margin: 0 auto 4px;
}
.progressbar li:after {
content: '';
width: 85%;
height: 3px;
position: absolute;
left: -42%;
top: 17px;
z-index: -1;
}
.progressbar::after {
content: '';
width: 68%;
height: 3px;
background: #B9B9B9;
position: absolute;
left: 17%;
top: 17px;
z-index: -2;
}
.progressbar li:first-child:after {
content: none;
}
.progress-payment li {
width: 50%;
}
.progressbar li.active:after,
.progressbar li.active:before {
background: #27ae60;
color: white;
}
.progressbar li.half-complete:before {
color: white;
}
.progressbar li.complete:after {
background: #27ae60;
}
.progressbar li.half-complete:after {
transform: scaleX(0);
color: white;
animation: fill 100ms linear forwards;
transform-origin: left;
animation-delay: inherit;
animation-play-state: paused;
background-color: #27ae60;
}
#keyframes fill {
to {
transform: scaleX(1);
}
}
<ul class="progressbar">
<li class="complete">Order Placed</li>
<li class="complete">Shipped</li>
<li class="active">Completed</li>
<li class="half-complete">Settled</li>
</ul>
<input id="progress" type="range" min="0" max="100">