css step wizard z-index not working - html

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.

Related

CSS process flow arrows - bad formatting?

I modified 3 different peoples code to make css arrows and I think I made it more complicated than it needs to be. Any CSS expert than can help me clean this up?
I can't seem to modify padding and other attributes to get this where I want it within the divs.
css
<style>
/* These are the Stage Arrows - styles */
#testStatus {
position: relative;
width: auto;
height: 30px;
left: 10px;
}
.testStatus li {
position: relative;
text-indent: 10px;
height: 30px;
display: inline-block;
zoom: 1;
margin-left: -3px;
padding: 10px 10px 10px 10px;
color: white;
font-size: 12px;
text-align: center;
line-height: auto;
}
ul.testStatus {
list-style: none;
}
li.testStatus:first-child:after, li.testStatusGood:after, li.testStatusNoGood:after {
content: "";
position: absolute;
width: 0;
height: 0;
border-top: 15px solid transparent;
border-left: 10px solid #767676;
border-bottom: 15px solid transparent;
margin: -10px 0px 0px 10px;
z-index: 3;
}
li.testStatus:last-child:before, li.testStatusGood:before, li.testStatusNoGood:before {
content: "";
position: absolute;
width: 0;
height: 0;
left: 0;
border-top: 15px solid transparent;
border-left: 10px solid #EEEEEE;
border-bottom: 15px solid transparent;
margin: -10px 0px 0px 0px;
z-index: 2;
}
li.testStatus:first-child {
padding-left: 10px;
margin-left: 0;
background-color: #767676;
}
li.testStatus:last-child {
padding-right: 10px;
background-color: #767676;
}
li.testStatusGood {
background-color: #77a942;
}
li.testStatusGood:after {
border-left: 10px solid #77a942;
}
li.testStatusNoGood {
background-color: #c42c00;
}
li.testStatusNoGood:after {
border-left: 10px solid #c42c00;
}
/* End arrow formatting */
</style>
html
<ul>
<li>
<div id="testStatus">
<ul class="testStatus">
<li class="testStatus">Step 1</li>
<li class="testStatusGood">Step 2</li>
<li class="testStatusNoGood">Step 3</li>
<li class="testStatusNoGood">Step 4</li>
<li class="testStatus">Step 5</li>
</ul>
</div>
</li>
</ul>
My arrows display nicely but I am having difficulty adjusting the padding to 0. I've tried the #, the ul class, the il class and I am a bit baffled why I cannot remove the 10px (I believe its the padding).
There is also a faintly darker border on the left side of the triangular portion of the arrows, if you look closely, that I'd like to have match the color exactly.
Duo's code output above image, Ojer code output below image
I'm going backwards :)
Here you go:
.breadcrumbs {
border: 1px solid #cbd2d9;
border-radius: 0.3rem;
display: inline-flex;
overflow: hidden;
}
.breadcrumbs__item {
background: #fff;
color: #333;
outline: none;
padding: 0.75em 0.75em 0.75em 1.25em;
position: relative;
text-decoration: none;
transition: background 0.2s linear;
}
.breadcrumbs__item:hover:after,
.breadcrumbs__item:hover {
background: #edf1f5;
}
.breadcrumbs__item:focus:after,
.breadcrumbs__item:focus,
.breadcrumbs__item.is-active:focus {
background: #323f4a;
color: #fff;
}
.breadcrumbs__item:after,
.breadcrumbs__item:before {
background: white;
bottom: 0;
clip-path: polygon(50% 50%, -50% -50%, 0 100%);
content: "";
left: 100%;
position: absolute;
top: 0;
transition: background 0.2s linear;
width: 1em;
z-index: 1;
}
.breadcrumbs__item:before {
background: #cbd2d9;
margin-left: 1px;
}
.breadcrumbs__item:last-child {
border-right: none;
}
.breadcrumbs__item.is-active {
background: #edf1f5;
}
/* Some styles to make the page look a little nicer */
body {
color: #323f4a;
background: #f5f7fa;
display: flex;
align-items: center;
justify-content: center;
}
html, body {
height: 100%;
}
.gray{
background-color:gray;
}
.breadcrumbs__item.gray:after{
background-color:gray;
}
.red{
background-color:red;
}
.breadcrumbs__item.red:after{
background-color:red;
}
.green{
background-color:green;
}
.breadcrumbs__item.green:after{
background-color:green;
}
<li class="breadcrumbs">
Prospect
Opportunity
Accound
Sales
Support
</li>
This can work for you.
Check this Pen
HTML:
<ul class="steps">
<li class="past">
<span>
<strong>Step 1</strong>
</span><i></i>
</li>
<li class="present">
<span>
<strong>Step 2</strong>
</span><i></i>
</li>
<li class="future">
<span>
<strong>Step 3</strong>
</span><i></i>
</li>
<li class="future1">
<span>
<strong>Step 4</strong>
</span><i></i>
</li>
<li class="present1">
<span>
<strong>Step 5</strong>
</span><i></i>
</li>
</ul>
CSS:
.steps {
padding-left: 0;
list-style: none;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 12px;
line-height: 1;
margin: 30px auto;
border-radius: 3px;
}
.steps strong {
font-size: 14px;
display: block;
line-height: 2.1;
}
.steps > li {
position: relative;
display: block;
/* border: 1px solid #ddd; */
padding: 12px 50px 8px 50px;
width: 140px;
height: 40px;
}
#media (min-width: 768px) {
.steps > li {
float: left;
}
.steps .past {
color: #fff;
background: blue;
}
.steps .present {
color: #000;
background: yellow;
}
.steps .future {
color: #fff;
background: green;
}
.steps .present1 {
color: #000;
background: red;
}
.steps .future1 {
color: #fff;
background: purple;
}
.steps .present1 {
color: #fff;
}
.steps li > span:after,
.steps li > span:before {
content: "";
display: block;
width: 0px;
height: 0px;
position: absolute;
top: 0;
left: 0;
border: solid transparent;
border-left-color: #f0f0f0;
border-width: 30px;
}
.steps li > span:after {
top: -4px;
z-index: 1;
border-left-color: white;
border-width: 34px;
}
.steps li > span:before {
z-index: 2;
}
.steps li.past + li > span:before {
border-left-color: blue;
}
.steps li.present + li > span:before {
border-left-color: yellow;
}
.steps li.future + li > span:before {
border-left-color: green;
}
.steps li.future1 + li > span:before {
border-left-color: purple;
}
.steps li:first-child > span:after,
.steps li:first-child > span:before {
display: none;
}
/* Arrows at start and end */
.steps li:first-child i,
.steps li:last-child i {
display: block;
position: absolute;
top: 0;
left: 0;
border: solid transparent;
border-left-color: white;
border-width: 30px;
}
.steps li:last-child i {
left: auto;
right: -30px;
border-left-color: transparent;
border-top-color: white;
border-bottom-color: white;
}
}

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;
}

How to display (<li>) menu items over divs - z-index not working

I am using a ul & li a bit like a select dropdown to trigger a JS function (not shown).
It's working fine - except the menu items appear BEHIND divs that are shown below them.
I've mocked up the problem here: http://jsfiddle.net/bf8ugef7/1/
I'm fiddling with z-index and position:absolute but can't see how to make it work.
Can anyone help?
Here is the HTML and CSS:
body {
font-family: sans-serif;
color: gray;
font-weight: 100;
}
div, li {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
li {
color: #333333;
text-decoration: none;
/* background-image: url("images/mullion.gif"); */
}
div.images {
border: 1px solid #555555;
/* padding-left: 5px; */
width: 100%;
float: left;
clear: left;
margin-bottom: 20px;
/*
background-image: url("images/iMullion.gif");
background-repeat: no-repeat;
*/
}
div.lowerText {
width: 100%;
}
div.btn {/* +filter */
float: right;
width: 195px;
cursor: default;
text-align: right;
/* margin-left: 1px; */
display: inline-block;
}
div.btn1 {
float: left;
width: 153px;
cursor: default;
text-align: center;
margin-left: 1px;
display: inline-block;
position: absolute;
color: black;
background-color: #79c1ee;
left: 182px;
}
div.btn2 {
float: left;
width: 20px;
display: inline-block;
color: white;
font-weight: 100;
text-align: center;
background-color: white;
cursor: default;
position: absolute;
left: 162px;
z-index: 100;
}
div.btn2 ul {
list-style: none;
position: absolute;
display: block;
margin: 0px;
padding: 0px;
z-index: 100;
}
div.btn2 ul li {
display: none;
cursor: pointer;
color: white;
height: 25px;
background-color: #79c1ee;
margin-top: 1px;
z-index: 100;
}
div.btn2 ul li:first-child {
margin-top: 0px;
display: inline-block;
width: 20px;
z-index: 100;
}
div.btn2 ul:hover {
height: 200px;
}
div.btn2 ul:hover li {
display: block;
z-index: 100;
}
div.btn2 ul li:hover {
background-color: #13A3E2;
z-index: 100;
}
/*
div.btn2 ul li:hover {
display: block;
width: 20px;
height: 100px;
}
*/
div.btn3 {
margin-left: 1px;
float: left;
width: 20px;
display: inline-block;
vertical-align: top;
text-align: center;
font-weight: 400;
color: white;
background-color: #13A3E2;
position: absolute;
left: 336px;
cursor: pointer;
}
div.btn3:hover {
background-color: red;
}
div.btn4 {
/* border: 1px solid black; */
padding-left: 5px;
float: left;
width: 153px;
display: inline-block;
color: #444444;
cursor: default;
background-color: white;
}
div.attr {
padding-left: 5px;
color: #444444;
background-color: #79C1ED;
float: right;
clear: none;
display: inline-block;
text-align: left;
}
div.filters {
width: 100%;
line-height: 1.8;
overflow: hidden;
display: block;
font-size: 14px;
text-decoration: none;
float: left;
}
div.toptext {
line-height: 2.2;
display: block;
max-height: 35px;
color: #444444;
background-color: #555555;/* matches border color */
color: white;
width: 100%;
padding-left: 5px;
cursor: not-allowed;
/* border: 1px solid pink; */
}
div.leftnav {
width: 350px;
float: left;
clear: left;
}
div#container {
padding: 0px;
margin: 0px;
}
<div class="leftnav">
<div class="images">
<div class="toptext">Filters
<div class="btn">+ filter</div>
</div>
<div id="container">
<div class="filters rem" id="f12">
<div class="btn4" id="b4f12">Pupil name</div>
<div class="btn2" id="b2f12">
<ul>
<li id="ddf_12_0">=</li>
<li id="ddf_12_1">></li>
</ul>
</div>
<div class="btn1" id="b1f12">Joe Bloggs</div>
<div class="btn3" id="if12">x</div>
</div>
<div class="filters rem" id="f13">
<div class="btn4" id="b4f13">Pupil name</div>
<div class="btn2" id="b2f13">
<ul>
<li id="ddf_13_0">=</li>
<li id="ddf_13_1">></li>
</ul>
</div>
<div class="btn1" id="b1f13">Bill Clinton</div>
<div class="btn3" id="if13">x</div>
</div>
</div>
</div>
</div>
Thanks
Emma
Try this code:
div.btn2 {
float: left;
width: 20px;
display: inline-block;
color: white;
font-weight: 100;
text-align: center;
background-color: white;
cursor: default;
left: 162px;
}
div.btn2 ul {
display: block;
margin: 0;
padding: 0;
}
div.btn2 ul li {
display: none;
cursor: pointer;
color: white;
height: 25px;
background-color: #79c1ee;
}
div.btn2 ul li:first-child {
display: inline-block;
border-top: none;
width: 20px;
}
div.btn2:hover li {
display: block;
position: absolute;
width: 20px;
border-top: 1px solid #fff;
}
div.btn2:hover li:first-child {
position: relative;
}
div.btn2 ul li:hover {
background-color: #13A3E2;
}
# Claudiu Yes it should be comment, but i dont have enough points to add comments
div.btn2 {
width: 20px;
display: inline-block;
color: white;
font-weight: 100;
text-align: center;
cursor: pointer;
left: 162px;
}
div.btn2 ul {
display: block;
margin: 0;
padding: 0;
}
div.btn2 ul li {
display: none;
cursor: pointer;
color: white;
height: 25px;
background-color: #79c1ee;
}
div.btn2 ul li:first-child {
display: inline-block;
width: 20px;
}
div.btn2:hover li {
display: block;
position: absolute;
width: 20px;
background: #000;
}
div.btn2:hover li:first-child {
position: relative;
}
div.btn2 ul li:hover {
background-color: #13A3E2;
}
i have updated the fiddle

Styling a funnel stack layout using native CSS and HTML

I want to show the data like funnel stack as illustrated below.
I was able to create the taper using borders, for example:
<div class="taper"></div>
and using the following CSS:
.taper {
width: 200px;
height: 0px;
border-color: lightgray transparent;
border-style: solid;
border-width: 50px 25px 0 25px;
}
Of course, the idea would be to wrap this div.taper in a container, add other elements and position them as needed, a bit of work but doable.
However, I don't necessarily know how many lines (levels, 7 in this example) will be needed and I don't really want to do a lot of math to determine the width of each taper and so on.
If there a more bullet-proof way of doing this?
I don't want a JavaScript/jQuery based solution (trying to keep this lightweight) and would prefer to avoid background images (I may want to skin/customize the colors later and don't want to bother with image files).
Fiddle reference: http://jsfiddle.net/audetwebdesign/fBax3/
Browser support: modern browsers are fine, legacy support, as long as it degrades nicely.
TL;DR : see the example at http://jsfiddle.net/97Yr6/
A way to create a funnel stack is with pseudoelements: with this basic markup
<ul>
<li>1,234,567,890 <span>Tooltip: 0</span></li>
<li>234,567,890 <span>Tooltip: 0</span></li>
<li>23,456,789</li>
<li>2,345,678 <span>Tooltip: 0</span></li>
<li>234,567</li>
<li>23,567 <span>Tooltip: 0</span></li>
<li>4,567<span>Tooltip: 0</span></li>
<li>789</li>
<li>23 <span>Tooltip: 0</span></li>
<li>4 <span>Tooltip: 0</span></li>
</ul>
we could create the funnel using borders, so we can draw a kind of trapezoid as a background in this way:
ul {
position: relative;
overflow: hidden;
font: 14px Arial;
margin: 0; padding: 0;
list-style: none;
text-align: center;
}
ul:before {
content: "";
position: absolute;
z-index: -1;
left: 50%;
margin-left: -120px;
width: 0;
border-top: 800px solid #ccc;
border-left: 120px solid #fff;
border-right: 120px solid #fff;
}
The <ul> is 100% wide, so we could give it a text-align: center and all the amounts are properly centered
Then the space between elements could be obtained as well with pseudoelements again:
li:after,li:before {
content: "";
display: block;
height: 0.4em;
background: #fff;
width: 100%;
}
li:before { border-top: 1px dotted #ccc }
li:first-child:before { border: 0; }
while the tooltip text could be positioned (the <li> needs to have position: relative defined), trying to properly adjust both left and margin-left properties (especially for lower screen resolution, but you may use mediaqueries for this purpose), e.g.
li span {
position: absolute;
left: 60%;
white-space: nowrap;
margin-left: 100px;
}
li:nth-child(2) span { left: 59%; }
li:nth-child(3) span { left: 58% }
li:nth-child(4) span { left: 57% }
li:nth-child(5) span { left: 56% }
li:nth-child(6) span { left: 55% }
li:nth-child(7) span { left: 54% }
li:nth-child(8) span { left: 53% }
li:nth-child(9) span { left: 52% }
li:nth-child(10) span { left: 51% }
basically this example may work even on IE8 if you change each :nth-child with the adjacency selector (e.g. li + li + li + ... + span )
Hope it could be helpful.
Ryan,
Thanks for your code example! I took your example and changed it a bit to reflect my project needs. Maybe someone will find this helpful.
body {
font-family: Lato, Arial, Helvetica, sans-serif;
}
.center-text {
text-align: center;
margin: 0px auto;
}
.funnel {
width: 750px;
margin: 0 auto;
}
ul.one {
margin: 40px 278px;
padding: 0;
list-style: none;
text-align: center;
}
.one .funnel-top {
position: absolute;
top: -7px;
left: -199px;
z-index: 20;
width: 599px;
height: 14px;
background: #919eb1;
border-radius: 100%;
}
.one .funnel-bottom {
position: absolute;
bottom: -7px;
left: -20px;
z-index: 20;
width: 240px;
height: 16px;
background: #273445;
border-radius: 100%;
}
.one li {
font-size: 16px;
line-height: 70px;
height: 70px;
width: 200px;
position: relative;
background: #ccc;
color: #ffffff;
font-weight: bold;
}
.one li span {
background: rgba(255, 255, 255, 0.3);
padding: 5px 8px;
border-radius: 4px;
margin-left: 15px;
}
.one li:before {
content: "";
position: absolute;
z-index: 10;
left: 0%;
margin-left: -30px;
width: 30px;
border-top: 70px solid #ccc;
border-left: 30px solid transparent;
}
.one li:after {
content: "";
position: absolute;
z-index: 10;
right: 0%;
margin-left: 30px;
width: 30px;
border-top: 70px solid #ccc;
border-right: 30px solid transparent;
}
.one li:nth-child(1) {
background: #919eb1;
}
.one li:nth-child(1):before,
.one li:nth-child(1):after {
border-top-color: #919eb1;
}
.one li:nth-child(1):before {
width: 200px;
margin-left: -200px;
}
.one li:nth-child(1):after {
width: 200px;
margin-right: -200px;
}
.one li:nth-child(2) {
background: #8491a5;
}
.one li:nth-child(2):before,
.one li:nth-child(2):after {
border-top-color: #8491a5;
}
.one li:nth-child(2):before {
width: 170px;
margin-left: -170px;
}
.one li:nth-child(2):after {
width: 170px;
margin-right: -170px;
}
.one li:nth-child(3) {
background: #778599;
}
.one li:nth-child(3):before,
.one li:nth-child(3):after {
border-top-color: #778599;
}
.one li:nth-child(3):before {
width: 140px;
margin-left: -140px;
}
.one li:nth-child(3):after {
width: 140px;
margin-right: -140px;
}
.one li:nth-child(4) {
background: #6d7b8f;
}
.one li:nth-child(4):before,
.one li:nth-child(4):after {
border-top-color: #6d7b8f;
}
.one li:nth-child(4):before {
width: 110px;
margin-left: -110px;
}
.one li:nth-child(4):after {
width: 110px;
margin-right: -110px;
}
.one li:nth-child(5) {
background: #606f84;
}
.one li:nth-child(5):before,
.one li:nth-child(5):after {
border-top-color: #606f84;
}
.one li:nth-child(5):before {
width: 80px;
margin-left: -80px;
}
.one li:nth-child(5):after {
width: 80px;
margin-right: -80px;
}
.one li:nth-child(6) {
background: #536075;
}
.one li:nth-child(6):before,
.one li:nth-child(6):after {
border-top-color: #536075;
}
.one li:nth-child(6):before {
width: 50px;
margin-left: -50px;
}
.one li:nth-child(6):after {
width: 50px;
margin-right: -50px;
}
ul.two {
margin: 40px 278px;
padding: 0;
list-style: none;
text-align: center;
}
.two .funnel-top {
position: absolute;
top: -7px;
left: -199px;
z-index: 20;
width: 599px;
height: 14px;
background: #1b99e6;
border-radius: 100%;
}
.two .funnel-bottom {
position: absolute;
bottom: -7px;
left: -20px;
z-index: 20;
width: 240px;
height: 16px;
background: #003352;
border-radius: 100%;
}
.two li {
font-size: 16px;
line-height: 70px;
height: 70px;
width: 200px;
position: relative;
background: #ccc;
color: #ffffff;
font-weight: bold;
}
.two li span {
background: rgba(255, 255, 255, 0.3);
padding: 5px 8px;
border-radius: 4px;
margin-left: 15px;
}
.two li:before {
content: "";
position: absolute;
z-index: 10;
left: 0%;
margin-left: -30px;
width: 30px;
border-top: 70px solid #ccc;
border-left: 30px solid transparent;
}
.two li:after {
content: "";
position: absolute;
z-index: 10;
right: 0%;
margin-left: 30px;
width: 30px;
border-top: 70px solid #ccc;
border-right: 30px solid transparent;
}
.two li:nth-child(1) {
background: #1b99e6;
}
.two li:nth-child(1):before,
.two li:nth-child(1):after {
border-top-color: #1b99e6;
}
.two li:nth-child(1):before {
width: 200px;
margin-left: -200px;
}
.two li:nth-child(1):after {
width: 200px;
margin-right: -200px;
}
.two li:nth-child(2) {
background: #148ad3;
}
.two li:nth-child(2):before,
.two li:nth-child(2):after {
border-top-color: #148ad3;
}
.two li:nth-child(2):before {
width: 170px;
margin-left: -170px;
}
.two li:nth-child(2):after {
width: 170px;
margin-right: -170px;
}
.two li:nth-child(3) {
background: #117fc3;
}
.two li:nth-child(3):before,
.two li:nth-child(3):after {
border-top-color: #117fc3;
}
.two li:nth-child(3):before {
width: 140px;
margin-left: -140px;
}
.two li:nth-child(3):after {
width: 140px;
margin-right: -140px;
}
.two li:nth-child(4) {
background: #0b75b6;
}
.two li:nth-child(4):before,
.two li:nth-child(4):after {
border-top-color: #0b75b6;
}
.two li:nth-child(4):before {
width: 110px;
margin-left: -110px;
}
.two li:nth-child(4):after {
width: 110px;
margin-right: -110px;
}
.two li:nth-child(5) {
background: #006bac;
}
.two li:nth-child(5):before,
.two li:nth-child(5):after {
border-top-color: #006bac;
}
.two li:nth-child(5):before {
width: 80px;
margin-left: -80px;
}
.two li:nth-child(5):after {
width: 80px;
margin-right: -80px;
}
.two li:nth-child(6) {
background: #005f98;
}
.two li:nth-child(6):before,
.two li:nth-child(6):after {
border-top-color: #005f98;
}
.two li:nth-child(6):before {
width: 50px;
margin-left: -50px;
}
.two li:nth-child(6):after {
width: 50px;
margin-right: -50px;
}
<br />
<div class="funnel leads estimated">
<h2 class="center-text">Estimated 100 Day Lead Conversion</h2>
<ul class="one">
<li>
<div class="funnel-top"></div>
1574<span>Contacts</span>
</li>
<li>203<span>MQL2</span>
</li>
<li>112<span>MQL2</span>
</li>
<li>57<span>SAL</span>
</li>
<li>11<span>SQL</span>
</li>
<li>
<div class="funnel-bottom"></div>
4<span>Wins</span>
</li>
</ul>
</div>
<div class="funnel leads estimated">
<h2 class="center-text">Actual 100 Day Lead Conversion</h2>
<ul class="two">
<li>
<div class="funnel-top"></div>
1574<span>Contacts</span>
</li>
<li>203<span>MQL2</span>
</li>
<li>112<span>MQL2</span>
</li>
<li>57<span>SAL</span>
</li>
<li>11<span>SQL</span>
</li>
<li>
<div class="funnel-bottom"></div>
4<span>Wins</span>
</li>
</ul>
</div>
View on JSFiddle
For those looking for a funnel with different colors for each layer in the stack:
http://jsfiddle.net/D9GLr/
HTML:
<ul>
<li>1,234,567,890</li>
<li>234,567,890</li>
<li>23,456,789</li>
<li>2,345,678</li>
<li>234,567</li>
</ul>
CSS:
ul {
margin: 0 200px; padding: 0;
list-style: none;
text-align: center;
}
li {
font-size:14px;
line-height:30px;
height:30px;
width:200px;
position:relative;
background:#ccc;
border-bottom:1px solid #fff;
}
li:before {
content: "";
position: absolute;
z-index: 10;
left: 0%;
margin-left: -30px;
width:30px;
border-top: 30px solid #ccc;
border-left: 30px solid transparent;
}
li:after {
content: "";
position: absolute;
z-index: 10;
right: 0%;
margin-left: 30px;
width:30px;
border-top: 30px solid #ccc;
border-right: 30px solid transparent;
}
li:nth-child(1) { background:#ddd; }
li:nth-child(1):before,
li:nth-child(1):after { border-top-color:#ddd; }
li:nth-child(1):before { width:200px; margin-left: -200px; }
li:nth-child(1):after { width:200px; margin-right:-200px; }
li:nth-child(2) { background:#bbb; }
li:nth-child(2):before,li:nth-child(2):after { border-top-color:#bbb; }
li:nth-child(2):before { width:170px; margin-left: -170px; }
li:nth-child(2):after { width:170px; margin-right:-170px; }
li:nth-child(3) { background:#999; }
li:nth-child(3):before,
li:nth-child(3):after { border-top-color:#999; }
li:nth-child(3):before { width:140px; margin-left: -140px; }
li:nth-child(3):after { width:140px; margin-right:-140px; }
li:nth-child(4) { background:#777; }
li:nth-child(4):before,
li:nth-child(4):after { border-top-color:#777; }
li:nth-child(4):before { width:110px; margin-left: -110px; }
li:nth-child(4):after { width:110px; margin-right:-110px; }
li:nth-child(5) { background:#555; }
li:nth-child(5):before,
li:nth-child(5):after { border-top-color:#555; }
li:nth-child(5):before { width:80px; margin-left: -80px; }
li:nth-child(5):after { width:80px; margin-right:-80px; }
I like the approach of dividing it into few divs.
See the code here
I have to add code so an example:
<div class="cont">
<div class="taper-left"></div>
<div class="taper-center">123,456,789</div>
<div class="taper-right"></div>
</div>
and the CSS:
.taper-right {
width: 25px;
height: 0px;
border-color: lightgray transparent;
border-style: solid;
border-width: 50px 25px 0 0px;
float: left;
}
.taper-left {
width: 25px;
height: 0px;
border-color: lightgray transparent;
border-style: solid;
border-width: 50px 0px 0px 25px;
float: left;
}
.taper-center {
width: 200px;
height: 34px;
border-color: lightgray transparent;
border-style: solid;
background-color: lightgray transparent;
background-color: lightgray;
float: left;
text-align: center;
padding-top: 10px;
}
Here's another take on it, this version is a bit more responsive: https://jsfiddle.net/ehynds/j3fL6hof
.funnel {
list-style-type: none;
margin: 0;
padding: 0;
text-align: center;
color: #fff;
background-color: #fff;
}
li {
padding: 10px 5px;
margin: 0;
background-color: #409ca9;
margin-bottom: 5px;
position: relative;
overflow: hidden;
}
div:last-child {
font-size: 36px
}
li:last-child {
background-color: #a5c13f;
}
li:before,
li:after {
content: '';
position: absolute;
top: 0;
height: 0;
border-bottom: 90px solid #fff;
}
li:before {
left: 0;
border-right: 27px solid transparent;
border-left: 0;
}
li:after {
right: 0;
border-left: 27px solid transparent;
border-right: 0;
}
li:nth-child(1):before,
li:nth-child(1):after {
width: 0;
}
li:nth-child(2):before,
li:nth-child(2):after {
width: 25px;
}
li:nth-child(3):before,
li:nth-child(3):after {
width: 50px;
}
li:nth-child(4):before,
li:nth-child(4):after {
width: 75px;
height: 100%;
border: 0;
background-color: #fff;
}
<ul class="funnel">
<li>
<div>First Segment</div>
<div>12,345</div>
</li>
<li>
<div>Second Segment</div>
<div>2,345</div>
</li>
<li>
<div>Third Segment</div>
<div>345</div>
</li>
<li>
<div>Fourth Segment</div>
<div>45</div>
</li>
</ul>