Horizontal CSS Wizard Navigation - html

I am trying to build up a horizontal css wizard navigation with a rounded css circle and text on each step. I am stuck on 1 point need to get ride on border from right side. Tried almost all steps. Attaching the code.
Attaching the screenshot of issue as well.
error image
ul {
text-align: justify;
position: relative;
overflow: hidden;
margin: 0;
padding: 0;
}
ul:before {
content: '';
width: 96%;
border: 2px solid #21a2d1;
position: absolute;
top: 1em;
margin-top: -6px;
z-index: -1;
margin-left: 16px;
}
.active:after {
content: '';
width: 100%;
border: 2px solid #b7b7b7;
position: absolute;
top: 1em;
margin-top: -6px;
z-index: -1;
}
ul:after {
content: '';
display: inline-block;
width: 100%;
}
li {
width: 1.5em;
height: 1.5em;
text-align: center;
line-height: 1.7em;
border-radius: 50%;
background: #21a2d1;
margin: 0 1em;
display: inline-block;
}
.marker-number {
font-size: 14px;
}
li.active {
background: #04497b;
}
.active ~ li {
background: #b7b7b7;
}
span.marker-text {
color: #7d7d7d;
font-size: 12px;
line-height: 16px;
width: 70px;
display: block;
margin-left: -21px;
font-family: Arial;
}
<ul>
<li><span class="marker-number"> </span> <span class="marker-text">Select Car</span></li>
<li><span class="marker-number"> </span> <span class="marker-text">Questions</span></li>
<li class="active"><span class="marker-number"> </span> <span class="marker-text">Problems</span></li>
<li><span class="marker-number"> </span> <span class="marker-text">Inspection</span></li>
<li><span class="marker-number"> </span> <span class="marker-text">Solution</span></li>
</ul>

Here is a sample, using flexbox, with a minimal markup, and for the marker the ::before pseudo and the line the ::after pseudo (starting from the 2:nd position)
ul.wizard, ul.wizard li {
margin: 0;
padding: 0;
display: flex;
width: 100%;
}
ul.wizard {
counter-reset: num;
}
ul.wizard li {
flex-direction: column;
align-items: center;
position: relative;
}
ul.wizard li::before {
counter-increment: num;
content: counter(num);
width: 1.5em;
height: 1.5em;
text-align: center;
line-height: 1.5em;
border-radius: 50%;
background: #21a2d1;
}
ul.wizard li ~ li::after {
content: '';
position: absolute;
width: 100%;
right: 50%;
height: 4px;
background-color: #21a2d1;
top: calc(.75em - 2px);
z-index: -1;
}
ul.wizard li.active::before {
background: #04497b;
color: white;
}
ul.wizard .active ~ li::before,
ul.wizard .active ~ li::after {
background: #b7b7b7;
}
ul.wizard span {
color: #7d7d7d;
font-size: 12px;
font-family: Arial;
}
/* updated sample */
ul.wizard li.completed::before { /* number and circle */
background: red;
color: white;
}
ul.wizard li.completed span { /* text */
color: red;
}
ul.wizard li.completed + li::after { /* line after circle */
background: red;
}
ul.wizard li.completed::after { /* line before circle */
background: red;
}
<ul class="wizard">
<li>
<span>Select Car</span>
</li>
<li class="completed">
<span>Questions</span>
</li>
<li class="active">
<span>Problems</span>
</li>
<li>
<span>Inspection</span>
</li>
<li>
<span>Solution</span>
</li>
</ul>
This can also be done without flexbox, if you need to target older browsers
ul.wizard, ul.wizard li {
margin: 0;
padding: 0;
}
ul.wizard {
counter-reset: num;
}
ul.wizard li {
list-style-type: none;
float: left;
width: 20%;
position: relative;
text-align: center;
}
ul.wizard li::before {
display: block;
counter-increment: num;
content: counter(num);
width: 1.5em;
height: 1.5em;
text-align: center;
line-height: 1.5em;
border-radius: 50%;
background: #21a2d1;
margin: 0 auto;
}
ul.wizard li ~ li::after {
content: '';
position: absolute;
width: 100%;
right: 50%;
height: 4px;
background-color: #21a2d1;
top: calc(.75em - 2px);
z-index: -1;
}
ul.wizard li.active::before {
background: #04497b;
color: white;
}
ul.wizard .active ~ li::before,
ul.wizard .active ~ li::after {
background: #b7b7b7;
}
ul.wizard span {
display: inline-block;
color: #7d7d7d;
font-size: 12px;
font-family: Arial;
}
<ul class="wizard">
<li>
<span>Select Car</span>
</li>
<li>
<span>Questions</span>
</li>
<li class="active">
<span>Problems</span>
</li>
<li>
<span>Inspection</span>
</li>
<li>
<span>Solution</span>
</li>
</ul>

Reduce width of pseudo element :befor to 90% and :after to 45% but you have to write it always different width percentages as per the activated li tag and as per screen size. I think If you modify your markup a little bit which will help you more and make the complications less.
============================================================
Changed markup as you required and few tweaks in css
ul {
text-align: justify;
position: relative;
overflow: hidden;
margin: 0;
padding: 0;
display: inline-flex;
justify-content: space-around;
width: 100%;
}
li {
position: relative;
width: 20%;
text-align: center;
display: inline;
padding-bottom: 20px;
}
.marker-number {
width: 1.5em;
height: 1.5em;
text-align: center;
line-height: 1.7em;
border-radius: 50%;
background: #21a2d1;
display: inline-block;
}
.marker-line {
position: absolute;
width: 100%;
height: 4px;
background-color: #21a2d1;
top: 10px;
}
li.active span.marker-number,
li.active span.marker-line {
background: #04497b;
}
.active ~ li span.marker-number,
.active ~ li span.marker-line {
background: #b7b7b7;
}
span.marker-text {
color: #7d7d7d;
font-size: 12px;
line-height: -15px;
font-family: Arial;
position: absolute;
left: 0;
right: 0;
bottom: 0;
}
<ul>
<li>
<span class="marker-number"> </span>
<span class="marker-line"></span>
<span class="marker-text">Select Car</span>
</li>
<li>
<span class="marker-number"> </span>
<span class="marker-line"></span>
<span class="marker-text">Questions</span>
</li>
<li class="active">
<span class="marker-number"> </span>
<span class="marker-line"></span>
<span class="marker-text">Problems</span>
</li>
<li>
<span class="marker-number"> </span>
<span class="marker-line"></span>
<span class="marker-text">Inspection</span>
</li>
<li>
<span class="marker-number"> </span>
<span class="marker-text">Solution</span>
</li>
</ul>

Related

Is it possible to make these arrows with html and css?

I am trying to use HTML and CSS instead of images to show some arrows -- Here is the image:
I'm trying to make these arrows with before and after pseudo-elements, but I have got problems.
Here's my code:
HTML:
<ul class="steps-list">
<li class="step-item">
Contact us
</li>
<li class="step-item">
Consult with RCIC
</li>
<li class="step-item">
Apply via your pathway
</li>
<li class="step-item">
Settle in Canada
</li>
</ul>
SASS:
.steps-list {
display: flex;
.step-item {
display: inline-block;
text-align: center;
width: 25%;
.step-link {
font-weight: bold;
background: #e2e3e4;
width: 100%;
display: inline-block;
padding: 2rem 1rem;
&:hover {
#include gradient(left, $gradientList2);
}
}
}
}
I have followed this article by the way:
https://css-tricks.com/snippets/css/css-triangle/
[Edit] After looking at your image again, I failed to account for the first element being flat. I have updated my answer.
Using before,after, and nth-child selectors, you can achieve what you showed in your image. The before and after pseudo elements are used to create the top and bottom half of the arrows while the nth-child selectors are used to make the arrows appear to be progressively closer together.
.steps-list {
display: flex;
list-style: none;
}
.steps-list .step-item {
position: relative;
display: flex;
align-items:center;
text-align: center;
width: 25%;
}
.steps-list .step-item .step-link {
font-weight: bold;
width: 100%;
display: inline-block;
padding:10px 5px;
box-sizing:border-box;
}
.step-link::before {
content: "";
display: block;
position: absolute;
transform: skew(-40deg, 0);
background: #e2e3e4;
height: 50%;
bottom: 0;
z-index: -1;
left:5px;
}
.step-link::after {
content: "";
display: block;
position: absolute;
transform: skew(40deg, 0);
background: #e2e3e4;
height: 50%;
top: 0;
z-index: -1;
left:5px;
}
.step-item:nth-child(1){
overflow:hidden;
}
.step-item:nth-child(1) .step-link::after {
width:95%;
left:-15px;
}
.step-item:nth-child(1) .step-link::before {
width: 95%;
left:-15px;
}
.step-item:nth-child(2) .step-link::after {
width: 90%;
}
.step-item:nth-child(2) .step-link::before {
width: 90%;
}
.step-item:nth-child(3) .step-link::after {
width: 95%;
}
.step-item:nth-child(3) .step-link::before {
width: 95%;
}
.step-item:nth-child(4) .step-link::after {
width: 100%;
}
.step-item:nth-child(4) .step-link::before {
width: 100%;
}
<ul class="steps-list">
<li class="step-item">
Contact us
</li>
<li class="step-item">
Consult with RCIC
</li>
<li class="step-item">
Apply via your pathway
</li>
<li class="step-item">
Settle in Canada
</li>
</ul>
Check this site
.clearfix:after {
clear: both;
content: "";
display: block;
height: 0;
}
.container {
font-family: 'Lato', sans-serif;
width: 1000px;
margin: 0 auto;
}
.wrapper {
display: table-cell;
height: 400px;
vertical-align: middle;
}
.nav {
margin-top: 40px;
}
.arrow-steps .step {
font-size: 14px;
text-align: center;
color: #666;
cursor: default;
margin: 0 3px;
padding: 10px 10px 10px 30px;
min-width: 180px;
float: left;
position: relative;
background-color: #d9e3f7;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
transition: background-color 0.2s ease;
}
.arrow-steps .step:after,
.arrow-steps .step:before {
content: " ";
position: absolute;
top: 0;
right: -17px;
width: 0;
height: 0;
border-top: 19px solid transparent;
border-bottom: 17px solid transparent;
border-left: 17px solid #d9e3f7;
z-index: 2;
transition: border-color 0.2s ease;
}
.arrow-steps .step:before {
right: auto;
left: 0;
border-left: 17px solid #fff;
z-index: 0;
}
.arrow-steps .step:first-child:before {
border: none;
}
.arrow-steps .step:first-child {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.arrow-steps .step span {
position: relative;
}
<div class="container">
<div class="wrapper">
<div class="arrow-steps clearfix">
<div class="step current"> <span> Step 1</span> </div>
<div class="step"> <span>Step 2 some words</span> </div>
<div class="step"> <span> Step 3</span> </div>
<div class="step"> <span>Step 4</span> </div>
</div>
</div>
</div>

Creating CSS circle steps connected with lines from top to the bottom

I already figure out to do the circle steps horizontally. But to do like the picture below is quite stressful. Can you figure out how to do this?
Here is code
.container-progress {
margin: 100px auto;
font-size: 24px;
font-weight: bold;
font-family: Verdana;
color: white;
margin-top: 50px;
padding: 0;
}
.progressbar {
margin: 0;
padding: 0;
counter-reset: step;
}
.progressbar li {
list-style-type: none;
width: 16%;
float: left;
font-size: 12px;
position: relative;
text-align: center;
text-transform: uppercase;
}
.progressbar li:before {
width: 5em;
height: 5em;
content: counter(step);
counter-increment: step;
line-height: 90px;
border: 2px solid #7d7d7d;
display: block;
text-align: center;
margin: 0 auto 10px auto;
padding: 0;
border-radius: 50%;
background-color: black;
font-size: 18px;
font-weight: bold;
}
.progressbar li:after {
margin-top: 30px;
width: 100%;
height: .5em;
content: '';
position: absolute;
background-color: #7d7d7d;
top: 15px;
left: -50%;
z-index: -1;
}
.progressbar li:first-child:after {
content: none;
}
.progressbar li.active {
color: white;
}
.progressbar li.active:before {
border-color: dodgerblue;
background: dodgerblue;
}
.progressbar li.active+li:after {
/*background-color: dodgerblue;*/
}
.progressbar label {
color: black;
}
<div class="container-progress">
<ul class="progressbar">
<li class="active active-step">
<label>step 1</label>
</li>
<li>
<label>step 2</label>
</li>
<li>
<label>step 3</label>
</li>
<li>
<label>step 4</label>
</li>
<li>
<label>step 5</label>
</li>
<li>
<label>step 6</label>
</li>
</ul>
</div>
Fiddle link
This uses a border on the ul to create your connecting lines and uses position:absolute to position the individual steps. You will probably need to tweak it a bit more but it could get you moving in the right direction.
Edit
To get the first three label to appear above ther cirlces, swap :before with :after. I've updated my code to reflect this.
.container-progress {
margin: 100px auto;
font-size: 24px;
font-weight: bold;
font-family: Verdana;
color: white;
margin-top: 50px;
padding: 0;
}
.progressbar {
margin: 0 50px;
padding: 0;
counter-reset: step;
position:relative;
border: 2px solid #7d7d7d;
border-left:none;
min-height:200px;
}
.progressbar li {
list-style-type: none;
width: 16%;
/*float: left;*/
font-size: 12px;
position: absolute;
text-align: center;
text-transform: uppercase;
}
/*First Three*/
.progressbar li:nth-child(-n+3)
{
top:-45px
}
/*Last Three*/
.progressbar li:nth-last-child(-n+3)
{
bottom:-75px
}
/*Left*/
.progressbar li:nth-child(1), .progressbar li:nth-child(6)
{
left:-45px
}
/*Middle*/
.progressbar li:nth-child(2), .progressbar li:nth-child(5)
{
left:calc(50% - 45px);
}
/*Right*/
.progressbar li:nth-child(3), .progressbar li:nth-child(4)
{
left:calc(100% - 45px);
}
.progressbar li:nth-last-child(-n+3):before, .progressbar li:nth-child(-n+3):after {
width: 5em;
height: 5em;
content: counter(step);
counter-increment: step;
line-height: 90px;
border: 2px solid #7d7d7d;
display: block;
text-align: center;
margin: 0 auto 10px auto;
padding: 0;
border-radius: 50%;
background-color: black;
font-size: 18px;
font-weight: bold;
}
/*.progressbar li:after {
margin-top: 30px;
width: 100%;
height: .5em;
content: '';
position: absolute;
background-color: #7d7d7d;
top: 15px;
left: -50%;
z-index: -1;
}*/
/*.progressbar li:first-child:after {
content: none;
}*/
.progressbar li.active {
color: white;
}
.progressbar li.active:before, .progressbar li.active:after {
border-color: dodgerblue;
background: dodgerblue;
}
.progressbar li.active+li:after {
/*background-color: dodgerblue;*/
}
.progressbar label {
color: black;
}
<div class="container-progress">
<ul class="progressbar">
<li class="active active-step">
<label>step 1</label>
</li>
<li>
<label>step 2</label>
</li>
<li>
<label>step 3</label>
</li>
<li>
<label>step 4</label>
</li>
<li>
<label>step 5</label>
</li>
<li>
<label>step 6</label>
</li>
</ul>
</div>

How to add image on hover in <li>::after

I want a structure like this on <li> hover (Blue down arrow on center of every li)
But I'm unable to make this because i thought i will use this blue image as pseudo elements ::after but i have added ":" in between two <li>.
This is my html code :
<div class="quick-links col-md-12">
<p class="left" style="font-weight:600;font-family:calibri;">Go quickly
to</p>
<i class="fa fa-arrow-circle-right" style="color:#2ca5fa;padding:0px 3px 0px 12px;"></i>
<ul class="quick-ul">
<li>Mobiles</li>
<li>Sports</li>
<li>Tablets</li>
<li>Bath Towels</li>
<li>LED Bulbs</li>
<li>TV</li>
<li>Washing Machines</li>
<li>Laptops</li>
<li>Headphones</li>
<li>Fans</li>
<li>Travel</li>
<li>Books</li>
</ul>
</div>
This is my CSS code :
.quick-links {
height: 52px;
background-color: white;
margin-top: 20px;
display: inline-table;
padding-top: 13px;
border-top: 4px solid #0096ff;
}
.left {
float: left;
}
.quick-ul {
float: right;
display: inline-flex;
}
.quick-ul li {
font-family: calibri;
padding-right: 39px;
position: relative;
margin-left: -34px;
font-size: 15px;
}
.quick-ul li>a {
color: black;
}
.quick-ul li>a:hover {
color: #0096ff;
}
.quick-ul li::after {
content: ":";
color: black;
padding-left: 10px;
padding-right: 10px;
font-weight: 100 !important;
}
.quick-ul li:nth-last-child(1)::after{
content: "";
}
Any Kind of help would be highly appreciated.
All you need is this rule
.quick-ul li>a:hover::after
content: "\25bc";
position: absolute;
left: 50%;
top: 0;
transform: translate(-50%, -100%) scaleX(2);
color: #0096ff;
font-size: 20px;
}
It will add a filled arrow character using the pseudo ::after, that is easily colored and sized as any other character. The translate moves it into place and the scaleX makes it a little wider.
Stack snippet
.quick-links {
height: 52px;
background-color: white;
margin-top: 20px;
display: inline-table;
border-top: 4px solid #0096ff;
}
.left {
float: left;
}
.quick-ul {
float: right;
display: inline-flex;
list-style: none; /* added property */
}
.quick-ul li {
font-family: calibri;
padding-right: 39px;
position: relative;
margin-left: -34px;
font-size: 15px;
}
.quick-ul li>a {
color: black;
}
.quick-ul li>a:hover {
position: relative; /* added property */
color: #0096ff;
}
.quick-ul li>a:hover::after { /* added rule */
content: "\25bc";
position: absolute;
left: 50%;
top: 0;
transform: translate(-50%, -100%) scaleX(2);
color: #0096ff;
font-size: 20px;
}
.quick-ul li::after {
content: ":";
color: black;
padding-left: 10px;
padding-right: 10px;
font-weight: 100 !important;
}
.quick-ul li:nth-last-child(1)::after {
content: "";
}
<div class="quick-links col-md-12">
<p class="left" style="font-weight:600;font-family:calibri;">Go quickly to
</p>
<i class="fa fa-arrow-circle-right" style="color:#2ca5fa;padding:0px 3px 0px 12px;"></i>
<ul class="quick-ul">
<li>Mobiles</li>
<li>Sports</li>
<li>Tablets</li>
<li>Bath Towels</li>
<li>LED Bulbs</li>
<li>TV</li>
</ul>
</div>
Try this.
.quick-links {
height: 52px;
background-color: white;
margin-top: 20px;
display: inline-table;
padding-top: 0;
border-top: 4px solid #0096ff;
}
.left {
float: left;
}
.quick-ul {
list-style: none;
float: right;
display: inline-flex;
}
.quick-ul li {
font-family: calibri;
font-size: 15px;
position: relative;
}
.quick-ul li>a {
color: black;
position: relative;
}
.quick-ul li>a:hover {
color: #0096ff;
}
.quick-ul li::after {
content: ":";
color: black;
padding-left: 10px;
padding-right: 10px;
font-weight: 100 !important;
}
.quick-ul li:nth-last-child(1)::after {
content: "";
}
/* additional styles */
.quick-ul li a::before {
content: "";
position: absolute;
top: -17px;
left: 50%;
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
border-top: 10px solid #0096ff;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
opacity: 0;
transition: all ease 0.15s;
}
.quick-ul li:hover a::before {
opacity: 1;
}
<div class="quick-links col-md-12">
<p class="left" style="font-weight:600;font-family:calibri;">Go quickly to
</p>
<i class="fa fa-arrow-circle-right" style="color:#2ca5fa;padding:0px 3px 0px 12px;"></i>
<ul class="quick-ul">
<li>Mobiles</li>
<li>Sports</li>
<li>Tablets</li>
<li>Bath Towels</li>
<li>LED Bulbs</li>
</ul>
</div>
This code should work for you:
.quick-links {
height: 52px;
background-color: white;
margin-top: 20px;
border-top: 4px solid #0096ff;
text-align: center;
padding: 0px !important;
}
.left {
float: left;
}
.quick-ul {
list-style: none;
display: flex;
justify-content: center;
margin: 0px;
box-sizing: border-box;
}
.quick-ul li {
position: relative;
font-family: Arial;
padding: 0px;
font-size: 15px;
margin: 0px 1px;
display: inline;
box-sizing: border-box;
}
.quick-ul li:not(:last-child)::before {
content: ":";
position: absolute;
top: 30%;
right: 0px;
height: 100%;
width: auto;
}
.quick-ul li>a {
display: block;
width: 100%;
height: 100%;
color: blue;
padding: 12px 18px 0px;
box-sizing: border-box;
position: relative;
}
.quick-ul li>a:hover {
color: #0096ff;
}
.quick-ul li > a::after {
display: block;
content: "";
color: blue;
padding-left: 10px;
padding-right: 10px;
font-weight: 100 !important;
transform: rotate(90deg);
transform: translateX(-50%) rotate(90deg);
margin-top: -5px;
font-size: 18px;
position: absolute;
top: 0px; left: 50%;
transition: all 0.3s ease-in-out;
}
.quick-ul li>a:hover::after {content: '\25B6'}
<div class="quick-links col-md-12">
<ul class="quick-ul">
<li>Mobiles</li>
<li>Sports</li>
<li>Tablets</li>
</ul>

Position of text within the block element

I need to make sure that if the text line is too long, it does not go above the price, but goes to a second line as soon as it approached the block with the price. I hope this makes sense. Please refer to the line 'Green tea with a tiny piece of lemon'. The word 'of' should not go above the line, it should have moved to the second line.
Any ideas how to fix this?
.lst {
font-family: montserrat;
width: 300px;
list-style-type: none;
position: relative;
}
ul.lst li {
position: relative;
}
ul.lst li a {
text-decoration: none;
color: #252525;
display: block;
padding: 5px;
position: relative;
border-bottom: 2px solid #f3f2e8;
z-index: 2;
}
ul.lst li em {
font-style: normal;
float: right;
width: 25%;
color: orange;
}
ul.lst li span {
position: absolute;
top: 0;
left: 0;
display: block;
height: 100%;
text-indent: -9999px;
background: #BFD3EE;
opacity: 0.5;
}
ul.lst li:hover span {
background: #658BBB;
}
ul.lst li:hover a{
color: #61304B;
}
ul.lst li:hover em{
color: #61304B;
}
<ul class="lst">
<li>Americano<em>$2.24</em><span style="width:20%">20%</span></li>
<li>Green tea with a tiny piece of lemon<em>$22.50</em><span style="width: 50%">50%</span></li>
<li>Black Tea<em>$2</em><span style="width: 75%">75%</span></li>
<li>Black coffee<em>$2</em><span style="width: 90%">90%</span></li>
<li>Latte<em>$2</em><span style="width: 50%">100%</span></li>
</ul>
You can set display: flex on a and that should fix the problem.
.lst {
font-family: montserrat;
width: 300px;
list-style-type: none;
position: relative;
}
ul.lst li {
position: relative;
}
ul.lst li a {
text-decoration: none;
color: #252525;
display: flex;
align-items: center;
padding: 5px;
position: relative;
border-bottom: 2px solid #f3f2e8;
z-index: 2;
}
ul.lst li em {
font-style: normal;
margin-left: auto;
width: 25%;
color: orange;
}
ul.lst li span {
position: absolute;
top: 0;
left: 0;
display: block;
height: 100%;
text-indent: -9999px;
background: #BFD3EE;
opacity: 0.5;
}
ul.lst li:hover span {
background: #658BBB;
}
ul.lst li:hover a {
color: #61304B;
}
ul.lst li:hover em {
color: #61304B;
}
<ul class="lst">
<li>Americano<em>$2.24</em><span style="width:20%">20%</span></li>
<li>Green tea with a tiny piece of lemon<em>$22.50</em><span style="width: 50%">50%</span></li>
<li>Black Tea<em>$2</em><span style="width: 75%">75%</span></li>
<li>Black coffee<em>$2</em><span style="width: 90%">90%</span></li>
<li>Latte<em>$2</em><span style="width: 50%">100%</span></li>
</ul>
Change a structure of your HTML a little bit and change your <a> to flexbox i.e. from display: block to display: flex.
Have a look at the snippet below:
.lst {
font-family: montserrat;
width: 300px;
list-style-type: none;
position: relative;
}
ul.lst li {
position: relative;
}
ul.lst li a {
text-decoration: none;
color: #252525;
display: flex;
padding: 5px;
position: relative;
border-bottom: 2px solid #f3f2e8;
z-index: 2;
}
ul.lst li a .text {
flex: 1;
}
ul.lst li em {
font-style: normal;
float: right;
width: 25%;
color: orange;
}
ul.lst li span {
position: absolute;
top: 0;
left: 0;
display: block;
height: 100%;
text-indent: -9999px;
background: #BFD3EE;
opacity: 0.5;
}
ul.lst li:hover span {
background: #658BBB;
}
ul.lst li:hover a{
color: #61304B;
}
ul.lst li:hover em{
color: #61304B;
}
<ul class="lst">
<li>
<a href="#">
<div class="text">Americano</div>
<em>$2.24</em>
</a>
<span style="width:20%">20%</span>
</li>
<li>
<a href="#">
<div class="text">Green tea with a tiny piece of lemon</div>
<em>$22.50</em>
</a>
<span style="width: 50%">50%</span></li>
<li>
<a href="#">
<div class="text">Black Tea</div>
<em>$2</em>
</a>
<span style="width: 75%">75%</span>
</li>
<li>
<a href="#">
<div class="text">Black coffee</div>
<em>$2</em>
</a>
<span style="width: 90%">90%</span>
</li>
<li>
<a href="#">
<div class="text">Latte</div>
<em>$2</em>
</a>
<span style="width: 50%">100%</span>
</li>
</ul>
Hope this helps!
How about the price with absolute position and some padding for the link text so it doesn't go on the price? something like this:
ul.lst li a {
text-decoration: none;
color: #252525;
display: block;
padding: 5px;
position: relative;
border-bottom: 2px solid #f3f2e8;
z-index: 2;
padding-right: 60px;
}
ul.lst li em {
font-style: normal;
float: right;
color: orange;
position: absolute;
right: 0;
width: auto;
}

Using css calc() with step

We have used a pure css base progress bar.
The main css part is as below.
.container {
width: 600px;
margin: 20px auto;
}
.progressbar {
margin: 0;
padding: 0;
counter-reset: step;
}
.progressbar li {
list-style-type: none;
width: 25%;
float: left;
font-size: 12px;
position: relative;
text-align: center;
text-transform: uppercase;
color: #7d7d7d;
}
.progressbar li:before {
width: 30px;
height: 30px;
content: counter(step);
counter-increment: step;
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;
}
...............
The html
<div class="container">
<ul class="progressbar">
<li class="active">login</li>
<li>choose interest</li>
........
Complete sample could be found at https://jsfiddle.net/wbj7e79p/.
As you can see it mess up for seven step. The reason is .progressbar li width which is fixed to 25% we wanted to make it dynamic base on number of steps.
So we tried width : calc (100% / steps) or calc (100% / counter(steps)) but none of them worked. Any idea !
Please consider that we are building a component which build a progress bar on the fly, so we can not find the actual number of steps
Did you consider flexbox?
body {
font-family: 'Alegreya Sans', sans-serif;
margin: 0;
padding: 0;
}
.container {
margin: 20px auto;
}
.progressbar {
margin: 0;
padding: 0;
counter-reset: step;
display: flex;
}
.progressbar li {
list-style-type: none;
flex: 1;
font-size: 12px;
position: relative;
text-align: center;
text-transform: uppercase;
color: #7d7d7d;
}
.progressbar li:before {
width: 30px;
height: 30px;
content: counter(step);
counter-increment: step;
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;
}
.progressbar li.active + li:after {
background-color: #55b776;
}
<h1>Four Steps</h1>
<div class="container">
<ul class="progressbar">
<li class="active">login</li>
<li>choose interest</li>
<li>add friends</li>
<li>View map</li>
</ul>
</div>
<h1> Seven Steps</h1>
<div class="container">
<ul class="progressbar">
<li class="active">login</li>
<li>choose interest</li>
<li>add friends</li>
<li>remove</li>
<li>fix users</li>
<li>review</li>
<li>save all</li>
</ul>
</div>