CSS Stepper - LI After overlaying LI Before - css

I'm using some code found at codepen with a Stepper Control. I'm not vey skilled with CSS and I'm having an issue not presented in codepen, so I assume is another CSS class defined in a very long stylesheet that is shared with other team mates. The problem I tried to fix is that the line defined in the class .progressbar li:after remains above the class .progressbar li:before, that defines the circles.
li:after initially came with a z-index: -1 and li:before didn't have the z-index property, but the lines didn't appear, they were hidden behind a div, so I had to modify it and that's what is shown in the snippet. Although this z-index: -1 works in the snippet, is not working where I want to be implemented.
This first image shows the result of the CSS Stepper, taken directly from codepen to my page with z-index:-1
This other image shows the result after trying to adjust the z-index property:
This is the desired output:
Here's the snippet:
.container {
width: 600px;
margin: 100px auto;
z-index: -1;
}
.progressbar li {
list-style-type: none;
width: 25%;
float: left;
font-size: 12px;
position: relative;
text-align: center;
text-transform: uppercase;
color: #666666;
}
.progressbar li:after {
width: 100%;
height: 2px;
content: '';
position: absolute;
background-color: #666666;
top: 15px;
left: -50%;
display: block;
z-index: 1;
}
.progressbar li:before {
width: 30px;
height: 30px;
content: '';
line-height: 30px;
border: 2px solid #666666;
display: block;
text-align: center;
margin: 0 auto 10px auto;
border-radius: 50%;
background-color: white;
z-index: 999999;
}
.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;
}
<div class="container">
<ul class="progressbar">
<li >aaaaaa</li>
<li class="active">bbbbbbbbbt</li>
<li>cccccccc</li>
<li>ddddddddd</li>
</ul>
</div>
¿Could I get some help to solve this problem, or where could I start looking?
I think it's all said, but please, if I left something, I'll try to complete the post.
Thanks in advance,

You just need to reduce the z-index of .progressbar li:after like this (no other changes required):
.progressbar li:after {
width: 100%;
height: 2px;
content: '';
position: absolute;
background-color: #666666;
top: 15px;
left: -50%;
display: block;
z-index: -999999;
}
You can see it working below:
.container {
width: 600px;
margin: 100px auto;
z-index: -1;
}
.progressbar li {
list-style-type: none;
width: 25%;
float: left;
font-size: 12px;
position: relative;
text-align: center;
text-transform: uppercase;
color: #666666;
}
.progressbar li:after {
width: 100%;
height: 2px;
content: '';
position: absolute;
background-color: #666666;
top: 15px;
left: -50%;
display: block;
z-index: -999999;
}
.progressbar li:before {
width: 30px;
height: 30px;
content: '';
line-height: 30px;
border: 2px solid #666666;
display: block;
text-align: center;
margin: 0 auto 10px auto;
border-radius: 50%;
background-color: white;
z-index: 999999;
}
.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;
}
<div class="container">
<ul class="progressbar">
<li>aaaaaa</li>
<li class="active">bbbbbbbbbt</li>
<li>cccccccc</li>
<li>ddddddddd</li>
</ul>
</div>

You must give the element a position-value in order to use z-index. Just apply position: relative; to the .progressbar li:before-element:
.container {
width: 600px;
margin: 100px auto;
}
.progressbar li {
list-style-type: none;
width: 25%;
float: left;
font-size: 12px;
position: relative;
text-align: center;
text-transform: uppercase;
color: #666666;
}
.progressbar li:after {
width: 100%;
height: 2px;
content: '';
position: absolute;
background-color: #666666;
top: 15px;
left: -50%;
display: block;
}
.progressbar li:before {
width: 30px;
height: 30px;
content: '';
line-height: 30px;
border: 2px solid #666666;
display: block;
text-align: center;
margin: 0 auto 10px auto;
border-radius: 50%;
background-color: white;
position: relative;
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;
}
<div class="container">
<ul class="progressbar">
<li>aaaaaa</li>
<li class="active">bbbbbbbbbt</li>
<li>cccccccc</li>
<li>ddddddddd</li>
</ul>
</div>

Related

How to make top-bar like sublime top-bar using real CSS?

I want to make like this but my top bar is to different i dont know how to make like this
.top-bar {
width: 100%;
height: 40px;
border: solid 1px white;
}
Please try following example. I think you can use or customize some value.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Lato', sans-serif;
font-size: 14px;
padding: 70px;
background: #f69ec4;
}
.tabs {
margin-bottom: 30px;
}
nav,
.content {
min-width: 600px;
}
.content {
max-width: 600px;
display: block;
margin-bottom: 1em;
background: #32557f;
padding: 2em 3em;
border-radius: .15em;
border: .2em solid #fff;
color: #fff;
}
nav {
position: relative;
z-index: 1;
}
nav > a {
position: relative;
width: 10em;
display: inline-block;
padding: .7em 2em .5em;
color: #fff;
text-decoration: none;
margin: 0 -.3em;
}
nav > a::before {
border: .2em solid #fff;
}
nav a::before {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: -1;
border-bottom: none;
border-radius: 1em 1em 0 0;
background: #7eb4e2;
transform: scale(1.2, 1.3) perspective(0.5em) rotateX(5deg);
}
nav a.active {
z-index: 2;
}
nav a.active::before {
background-color: #32557f;
margin-bottom: -.08em;
}
.tab-left-right nav {
padding-left: 1.3em;
}
.tab-left-right nav a::before {
transform-origin: bottom;
}
<div class="tabs tab-left-right">
<nav>
Tab1
Tab2
Tab3
</nav>
<div class="content" id="content1">Content</div>
</div>
I use ul list
.open-file-list {
position: absolute;
top: 45px;
top: var(--header-height);
height: 30px;
width: 100%;
background-color: var(--primary-color);
overflow-x: auto !important;
overflow-y: hidden !important;
display: flex;
flex-direction: row !important;
color: white;
color: var(--text-main-color)
}
.open-file-list li.tile {
min-width: -webkit-min-content;
min-width: -moz-min-content;
min-width: min-content;
height: 30px;
position: relative;
overflow: hidden;
font-size: 0.8em;
align-items: center;
margin: 0;
padding: 0;
color: inherit
}
.open-file-list li.tile::before{
position: absolute;
content: '';
background-color: black;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: -1;
border-bottom: none;
border-radius: 1em 1em 0 0;
background: #7eb4e2;
transform: scale(1.2, 1.3) perspective(0.5em) rotateX(5deg);
height: 30px;
}
.open-file-list li.tile.text{
display: inline-block;
white-space: nowrap;
max-width: 180px;
overflow: hidden;
text-overflow: ellipsis;
margin: 0;
padding-right: 10px;
color: inherit
}
.open-file-list li.tile.select {
position: absolute;
left: 0;
top: 0
}
.open-file-list li.tile.notice::before {
content: '♥';
color: #00ff00;
font-size: 1em;
margin-left: 2.5px
}
.open-file-list li.tile.active {
border-top: solid 2px #00ee00;
background-color: rgba(0,0,0,0.2)
}
.open-file-list li.tile .file,.open-file-list li.tile .icon {
height: 20px;
width: 20px;
font-size: 1em;
background-size: 14px;
background-position: center;
color: inherit
}

How to remove border from previous sibling?

I'm using a trick to add a border between navigation items
li {
&:not(.active) {
&::before {
border-bottom: grey;
bottom: 0;
content: '';
height: 1px;
left: 20px;
position: absolute;
width: 220px;
:host-context(.minified) {
display: none;
}
}
It works fine. You can see the yellow marked line.
If navigation is active i do not add this border.
If the navigation link is active, i would like to remove the border from previous sibling. You can see the red arrow.
Anybody ideas how can i do that?
You can define the divider at the top of the li and remove the first divider with li:first-child:after
Now, when hovering you can access the next li with + and set the background to be transparent.
Here's an example:
html, body{
padding: 0px;
margin: 0px;
}
ul {
border-right: 2px solid #e5e5e5;
width: 180px;
box-shadow: 5px 2px 10px #e5e5e5;
margin: 0px;
padding: 0px;
}
li {
list-style-type: none;
height: 40px;
display: flex;
align-items: center;
margin: 0px;
padding-left: 15px;
position: relative;
}
li:after{
position: absolute;
background-color: #e5e5e5;
top: 1px;
height: 1px;
width: 130px;
left: 20px;
z-index: 1;
content: "";
}
li:first-child:after{
height: 0px;
}
li:hover {
color: #13A83E;
background-color: #e5e5e5;
}
li:hover + li:after {
background-color: transparent;
}
<ul>
<li>Dashboard</li>
<li>Assets</li>
<li>Devices</li>
<li>More</li>
<li>Options</li>
</ul>

progressbar in css inside modal bootstrap z-index issue

I have my progresbar written in css and line between first and second circle hovers a little the number "2". The lines beetwen circles are pseudelements.
This is the styles i used:
/* progressbar */
.progressbar {
width: 100%;
counter-reset: step;
margin-top: 7px;
padding: 0;
}
.progressbar li {
list-style-type: none;
float: left;
width: 100px;
position: relative;
text-align: center;
font-family: sans-serif;
font-size: 15px;
font-weight: normal;
color: #546A79;
/* Steps*/
}
.progressbar li:before {
content: counter(step);
counter-increment: step;
width: 44px;
height: 44px;
line-height: 44px;
/* border: 4px solid #fff; */
display: block;
text-align: center;
margin: 0 auto 13px auto;
border-radius: 50%;
background-color: #E3E3E3;
/* Circles*/
}
.progressbar li:after {
content: '';
position: absolute;
width: 100%;
height: 4px;
background-color: #E3E3E3;
/*lines */
top: 20px;
left: -50%;
z-index: 0;
}
.progressbar li:first-child:after {
content: none;
}
.progressbar li.active {
color: #546A79;
}
.progressbar li.active:before {
width: 48px;
height: 48px;
line-height: 48px;
border-radius: 50%;
border-color: #0073CF;
color: black;
background-color: #ffda47;
margin: 0 auto 9px auto;
}
.progressbar li.active + li.active:after {
background-color: #ffda47;
}
Here's jsfiddle of the problem:
http://jsfiddle.net/1aeur58f/523/
.progressbar li {
list-style-type: none;
float: left;
width: 100px;
position: relative;
text-align: center;
font-family: sans-serif;
font-size: 15px;
font-weight: normal;
color: #546A79;
z-index:1;
}
.progressbar li:after {
content: '';
position: absolute;
width: 100%;
height: 4px;
background-color: #E3E3E3;
/*lines */
top: 20px;
left: -50%;
/*z-index: 0;*/
z-index: -1;
}
for ".progressbar li:after" now its z-index:-1; make this z-index:-1;
and z-index:1; for ".progressbar li" your ul item.

Create a vertical line with a circle in it and text on sides aligned to circles

I'm trying to implement the following on my website:
Obviously this should be able to go on for more iterations, I don't really know what to google for, I found a way to create a line, but I have no idea how to combine that with Circles and how to make those aligned with the text.
Final code:
* {
box-sizing: border-box;
}
ul {
margin: 0;
padding: 0;
list-style-type: none;
}
ul li div {
width: 50%;
float: left;
text-align: center;
}
ul li .zero-left {
position: relative;
color: #EB908B;
width: 30%;
text-align: right;
padding-right: 20px;
}
ul li .zero-right {
border-left: 3px solid #3C4C4C;
position: relative;
color: #3C4C4C;
width: 70%;
padding-left: 15px;
text-align: left;
}
ul li .first {
position: relative;
color: #EB908B;
width: 30%;
text-align: right;
padding-right: 20px;
}
ul li .second {
border-left: 3px solid #3C4C4C;
position: relative;
width: 70%;
padding-left: 15px;
text-align: left;
}
ul li .second p {
color: #EB908B;
position: relative;
text-align: left;
}
ul li .first::before {
content: '';
position: absolute;
right: -11.5px;
width: 20px;
height: 20px;
border-radius: 150%;
border: 2px solid #3C4C4C;
background: #3C4C4C;
z-index:9999
}
You can use after pseudo-element to put circle. Here I made an example with after solution.
jsfiddle

Creating CSS circles connected with lines vertical and horizontal

I want to create a circle with lines on the right and bottom in CSS. Similar on the picture below. I found a css code that connect circles horizontally. I cannot figure out how will add the line vertically or similar to the image I attached?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
#import "compass/css3";
li {
width: 2em;
height: 2em;
text-align: center;
line-height: 2em;
border-radius: 1em;
background: dodgerblue;
margin: 0 1em;
display: inline-block;
color: white;
position: relative;
}
li::before {
content: '';
position: absolute;
top: .9em;
left: -4em;
width: 4em;
height: .2em;
background: dodgerblue;
z-index: -1;
}
li:first-child::before {
display: none;
}
.active {
background: dodgerblue;
}
.active ~ li {
background: lightblue;
}
.active ~ li::before {
background: lightblue;
}
body {
font-family: sans-serif;
padding: 2em;
}
</style>
</head>
<body>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li class="active">4</li>
<li>5</li>
<li>6</li>
<li>7</li>
</ul>
</body>
</html>
Use a combination of pseudo-elements to achieve the goal.
ul {
list-style: none;
margin: 50px;
padding: 0;
font: normal 16px/22px Arial;
color: #999;
}
li {
overflow: hidden;
position: relative;
padding: 0 0 10px 35px;
}
li::before {
content: '';
position: absolute;
left: 9px;
top: 9px;
width: 20px;
height: 999px;
border: 2px solid lightblue;
border-width: 2px 0 0 2px;
}
li:last-child::before {
border-width: 2px 0 0;
}
li::after {
content: '';
position: absolute;
left: 0;
top: 0;
width: 16px;
height: 16px;
background: #fff;
border: 2px solid lightblue;
border-radius: 50%;
}
li.current,
li.passed {
color: #000;
}
li.current::before {
border-top-color: dodgerblue;
}
li.current::after {
border-color: dodgerblue;
background: dodgerblue;
}
li.passed::before,
li.passed::after {
border-color: dodgerblue;
}
<ul>
<li class="passed">Step #1</li>
<li class="passed">Step #2</li>
<li class="passed">Step #3</li>
<li class="current">Step #4<br><small><i>Description of the step</i></small></li>
<li>Step #5</li>
<li>Step #6</li>
<li>Step #7</li>
</ul>
See jsfiddle if you prefer
Check out updated pen :
http://codepen.io/Debabrata89/pen/QNZrxE
Below are the relevant code:
HTML:
<div></div><span id="step1">step1</span>
<div id="second"></div>
<div></div><span id="step2">step2</span>
<div id="last"></div>
CSS:
#import "compass/css3";
div {
width: 2em;
height: 2em;
text-align: center;
line-height: 2em;
border-radius: 1em;
background: dodgerblue;
margin: 0 1em;
color: white;
position: relative;
-ms-transform: rotate(-180deg);
-webkit-transform: rotate(-180deg);
transform: rotate(-180deg);
}
div::before{
content: '';
position: absolute;
top: .9em;
left: -4em;
width: 4em;
height: .2em;
background: dodgerblue;
z-index: -1;
}
div:first-child::after {
display: none;
}
body {
font-family: sans-serif;
padding: 2em;
}
#last{
transform: rotate(-90deg);
width:0;
height:0;
}
#second{
transform: rotate(-90deg);
width:0;
height:10;
left:16px;
top:-16px;
}
#step1{
position:absolute;
top:40px;
left:150px
}
#step2{
position:absolute;
top:104px;
left:150px
}
Try this fiddle .
I changed some properties and added li:after.
li {
width: 2em;
height: 2em;
text-align: center;
line-height: 2em;
border-radius: 1em;
background: dodgerblue;
margin: 1em 1em;
color: white;
position: relative;
}
li::before {
content: '';
position: absolute;
top: -4.1em;
left: 1em;
/* width: 4em; */
width: .2em;
height: 2em;
background: dodgerblue;
z-index: -1;
}
li::after {
content: '';
position: absolute;
top: 0.9em;
left: 1em;
width: 4em;
height: .2em;
background: dodgerblue;
z-index: -1;
}
li:first-child::before {
display: none;
}
.active {
background: dodgerblue;
}
.active ~ li {
background: lightblue;
}
.active ~ li::before {
background: lightblue;
}
body {
font-family: sans-serif;
padding: 2em;
}

Resources