css vertical form steps indicator? - css

I'm trying to create a vertical form steps indicator using css.
I found this https://codepen.io/erwinquita/pen/ZWzVRE which works fine in the codepen but when I try to copy the code from there and use it in my html page, the green circles do not show up!
I even copied the code and pasted it in jsfiddle but the same issue accrued.
this is the code:
.wrapper {
width: 330px;
font-family: 'Helvetica';
font-size: 14px;
border: 1px solid #CCC;
}
.StepProgress {
position: relative;
padding-left: 45px;
list-style: none;
&::before {
display: inline-block;
content: '';
position: absolute;
top: 0;
left: 15px;
width: 10px;
height: 100%;
border-left: 2px solid #CCC;
}
&-item {
position: relative;
counter-increment: list;
&:not(:last-child) {
padding-bottom: 20px;
}
&::before {
display: inline-block;
content: '';
position: absolute;
left: -30px;
height: 100%;
width: 10px;
}
&::after {
content: '';
display: inline-block;
position: absolute;
top: 0;
left: -37px;
width: 12px;
height: 12px;
border: 2px solid #CCC;
border-radius: 50%;
background-color: #FFF;
}
&.is-done {
&::before {
border-left: 2px solid green;
}
&::after {
content: "✔";
font-size: 10px;
color: #FFF;
text-align: center;
border: 2px solid green;
background-color: green;
}
}
&.current {
&::before {
border-left: 2px solid green;
}
&::after {
content: counter(list);
padding-top: 1px;
width: 19px;
height: 18px;
top: -4px;
left: -40px;
font-size: 14px;
text-align: center;
color: green;
border: 2px solid green;
background-color: white;
}
}
}
strong {
display: block;
}
}
<div class="wrapper">
<ul class="StepProgress">
<li class="StepProgress-item is-done"><strong>Post a contest</strong></li>
<li class="StepProgress-item is-done"><strong>Award an entry</strong>
Got more entries that you love? Buy more entries anytime! Just hover on your favorite entry and click the Buy button
</li>
<li class="StepProgress-item current"><strong>Post a contest</strong></li>
<li class="StepProgress-item"><strong>Handover</strong></li>
<li class="StepProgress-item"><strong>Provide feedback</strong></li>
</ul>
</div>
I don't understand what I am missing.
could someone please advice on this issue?

In the codepen link you've provided, LESS CSS Preprocessor has been used. That's why you couldn't replicate the same code with jsfiddle or your local instance. Simply, the CSS isn't working in your case, you are viewing the plain html because when you use the css preprocessor, browser can't render it directly.
If you want this code to work in jsfiddle, then you have to select SCSS as the language in the dropdown menu named as css in the css box. Here's the link that shows it is working: https://jsfiddle.net/9k67r0eg/1/
And if you want to use it in your local browser, then you may want to compile it. Check it here: http://lesscss.org/
However, the LESS can be converted to pure css also. Here's the converted code which you can use directly:
.wrapper {
width: 330px;
font-family: 'Helvetica';
font-size: 14px;
border: 1px solid #CCC;
}
.StepProgress {
position: relative;
padding-left: 45px;
list-style: none;
}
.StepProgress::before {
display: inline-block;
content: '';
position: absolute;
top: 0;
left: 15px;
width: 10px;
height: 100%;
border-left: 2px solid #CCC;
}
.StepProgress-item {
position: relative;
counter-increment: list;
}
.StepProgress-item:not(:last-child) {
padding-bottom: 20px;
}
.StepProgress-item::before {
display: inline-block;
content: '';
position: absolute;
left: -30px;
height: 100%;
width: 10px;
}
.StepProgress-item::after {
content: '';
display: inline-block;
position: absolute;
top: 0;
left: -37px;
width: 12px;
height: 12px;
border: 2px solid #CCC;
border-radius: 50%;
background-color: #FFF;
}
.StepProgress-item.is-done::before {
border-left: 2px solid green;
}
.StepProgress-item.is-done::after {
content: "✔";
font-size: 10px;
color: #FFF;
text-align: center;
border: 2px solid green;
background-color: green;
}
.StepProgress-item.current::before {
border-left: 2px solid green;
}
.StepProgress-item.current::after {
content: counter(list);
padding-top: 1px;
width: 19px;
height: 18px;
top: -4px;
left: -40px;
font-size: 14px;
text-align: center;
color: green;
border: 2px solid green;
background-color: white;
}
.StepProgress strong {
display: block;
}
<div class="wrapper">
<ul class="StepProgress">
<li class="StepProgress-item is-done"><strong>Post a contest</strong></li>
<li class="StepProgress-item is-done"><strong>Award an entry</strong> Got more entries that you love? Buy more entries anytime! Just hover on your favorite entry and click the Buy button
</li>
<li class="StepProgress-item current"><strong>Post a contest</strong></li>
<li class="StepProgress-item"><strong>Handover</strong></li>
<li class="StepProgress-item"><strong>Provide feedback</strong></li>
</ul>
</div>

Related

How to add an image to the back of a custom checkbox

I found a really clean looking custom checkbox on codepen and just updated a project to use it. Right now I've got the background colors different for the different sections of my form, but I'd like to just make background an icon rather than just a solid color
The commented out stuff doesn't work
.label-switch {
display: inline-block;
position: relative;
}
.label-switch::before,
.label-switch::after {
content: "";
display: inline-block;
cursor: pointer;
transition: all 0.5s;
}
.label-switch::before {
width: 3em;
height: 1em;
border: 1px solid #757575;
border-radius: 4em;
background: #888888;
}
.label-switch::after {
position: absolute;
left: 0;
top: -20%;
width: 1.5em;
height: 1.5em;
border: 1px solid #757575;
border-radius: 4em;
background: #ffffff;
}
.input-switch:checked~.label-switch::before {
background: #00a900;
border-color: #008e00;
}
.input-switch:checked~.label-switch::after {
left: unset;
right: 0;
background: #00ce00;
/*background-image:(url(http://pngimg.com/uploads/pokeball/pokeball_PNG8.png);*/
/*background: url(http://pngimg.com/uploads/pokeball/pokeball_PNG8.png);*/
border-color: #009a00;
}
<input class='input-switch' type="checkbox" id="demo" />
<label class="label-switch" for="demo"></label>
<span class="info-text"></span>
Everything you did was correct it's just the background image needed to have a background-position and background-size set if you toggle the checkbox in my snippet you should see the background pattern as you intended it to work.
.label-switch{
display: inline-block;
position: relative;
}
.label-switch::before, .label-switch::after{
content: "";
display: inline-block;
cursor: pointer;
transition: all 0.5s;
}
.label-switch::before {
width: 3em;
height: 1em;
border: 1px solid #757575;
border-radius: 4em;
background: #888888;
}
.label-switch::after {
position: absolute;
left: 0;
top: -20%;
width: 1.5em;
height: 1.5em;
border: 1px solid #757575;
border-radius: 4em;
background: #ffffff;
}
.input-switch:checked ~ .label-switch::before {
background: #00a900;
border-color: #008e00;
}
.input-switch:checked ~ .label-switch::after {
left: unset;
right: 0;
background: #00ce00;
background-image:url(http://pngimg.com/uploads/pokeball/pokeball_PNG8.png);
background-size:contain;
background-position:center;
border-color: #009a00;
}
<input class='input-switch' type="checkbox" id="demo"/>
<label class="label-switch" for="demo"></label>
<span class="info-text"></span>

Positioning left/right toggle/trigger and corresponding menu of a dropdown menu

I'm trying to position left and right variations of a dropdown menu.
My problem is with the toggle(dropdown__toggle) I try to position right, but it doesn't work; I want the toggle to be above the menu triangle;
I use a position:relative for it, if I try position:absolute it's creating a mess.
I want the toggle and menu to not have a fixed width because I need to use it in multiple situations.
.dropdown--right {
position: relative; }
.dropdown__toggle {
display:inline-block;
text-align:right;
position:relative;
right:0;
cursor: pointer; }
.dropdown__menu {
background-color: #E3E3E3;
background-clip: padding-box;
border: 1px solid #BDBDBD;
border-radius: 0.1875rem;
color: #0b0b0b;
list-style: none;
margin: 4px 0 0 0;
min-width: 10rem;
opacity: 1;
padding: 0;
right:0;
position: absolute;
pointer-events: none;
text-align: left;
top: 100%;
z-index: 99; }
.dropdown__menu__item {
display: block;
padding: 0.5rem 0.5rem;
width: 100%;
white-space: nowrap; }
.dropdown__menu:after {
border-style: solid;
bottom: 100%;
content: "";
height: 0;
position: absolute;
width: 0; }
.dropdown__menu:after {
border-style: solid;
bottom: 100%;
content: "";
height: 0;
position: absolute;
width: 0; }
.c-dropdown--right-triangle .c-dropdown__menu:before {
border-style: solid;
bottom: 100%;
content: "";
height: 0;
position: absolute;
width: 0;
right: 16px;
border-width: 0 10px 10px 10px;
border-color: #BDBDBD transparent; }
.dropdown__menu::after {
border-style: solid;
bottom: 100%;
content: "";
height: 0;
position: absolute;
width: 0;
right: 18px;
border-width: 0 8px 8px 8px;
border-color: #E3E3E3 transparent; }
<div>
<div class="dropdown--right" data-dropdown>
<a class="dropdown__toggle" >Toggle</a>
<ul class="dropdown__menu" data-dropdown-menu>
<li class="dropdown__menu__item"><a>Cameras</a></li>
<li class="dropdown__menu__item"><a>Cameras</a></li>
<li class="dropdown__menu__item"><a>Cameras</a></li>
</ul>
</div>
</div>
I added some styling and a class so you can use dropdown--left or dropdown--right to choose the display of your dropdown:
/* COMMON STYLE */
.dropdown__toggle {
display: inline-block;
position: relative;
cursor: pointer;
}
.dropdown__menu {
background-color: #E3E3E3;
background-clip: padding-box;
border: 1px solid #BDBDBD;
border-radius: 0.1875rem;
color: #0b0b0b;
list-style: none;
margin: 4px 0 0 0;
min-width: 10rem;
opacity: 1;
padding: 0 0.5rem;
position: absolute;
pointer-events: none;
top: 100%;
z-index: 99;
}
.dropdown__menu__item {
display: block;
padding: 0.5rem 0;
width: 100%;
white-space: nowrap;
}
.dropdown__menu::after {
border-style: solid;
bottom: 100%;
content: "";
height: 0;
position: absolute;
width: 0;
border-width: 0 8px 8px 8px;
border-color: #E3E3E3 transparent;
}
/* LEFT STYLE */
.dropdown--left {
position: relative;
text-align: left;
}
.dropdown--left .dropdown__menu {
left: 0;
text-align: right;
}
.dropdown--left .dropdown__menu::after {
left: 18px;
}
/* RIGHT STYLE */
.dropdown--right {
position: relative;
text-align: right;
}
.dropdown--right .dropdown__menu {
right: 0;
text-align: left;
}
.dropdown--right .dropdown__menu::after {
right: 18px;
}
<div>
<div class="dropdown--left" data-dropdown>
<a class="dropdown__toggle">Toggle</a>
<ul class="dropdown__menu" data-dropdown-menu>
<li class="dropdown__menu__item"><a>Cameras</a></li>
<li class="dropdown__menu__item"><a>Cameras</a></li>
<li class="dropdown__menu__item"><a>Cameras</a></li>
</ul>
</div>
</div>
<br><br>
<div>
<div class="dropdown--right" data-dropdown>
<a class="dropdown__toggle">Toggle</a>
<ul class="dropdown__menu" data-dropdown-menu>
<li class="dropdown__menu__item"><a>Cameras</a></li>
<li class="dropdown__menu__item"><a>Cameras</a></li>
<li class="dropdown__menu__item"><a>Cameras</a></li>
</ul>
</div>
</div>
Hope it helps.
If you want the class dropdown--right to also align the text in dropdown__toggle to the right, I think all you need is to include text-align.
.dropdown--right {
position: relative;
text-align: right; <-- Added CSS
}
Since you're going to be using this dropdown menu in multiple situations/components, I think it's as simple as adding position: absolute; and right: 0; to the .dropdown--right element, because you're going to be using it in other html elements anyway. And then for the left version of this component it'll be as easy as replacing the right: 0; with left: 0;
<div class="dropdown__containerexample">
<div class="dropdown--right" data-dropdown>
<a class="dropdown__toggle" >Toggle</a>
<ul class="dropdown__menu" data-dropdown-menu>
<li class="dropdown__menu__item"><a>Cameras</a></li>
<li class="dropdown__menu__item"><a>Cameras</a></li>
<li class="dropdown__menu__item"><a>Cameras</a></li>
</ul>
</div>
</div>
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.dropdown__containerexample {
position: relative;
width: 50%;
height: 200px;
border: 1px solid #000; }
.dropdown--right {
position: absolute;
right: 0; }
.dropdown__toggle {
cursor: pointer; }
.dropdown__menu {
background-color: #E3E3E3;
background-clip: padding-box;
border: 1px solid #BDBDBD;
border-radius: 0.1875rem;
color: #0b0b0b;
list-style: none;
margin: 4px 0 0 0;
min-width: 10rem;
opacity: 1;
padding: 0;
right:0;
position: absolute;
pointer-events: none;
text-align: left;
top: 100%;
z-index: 99; }
.dropdown__menu__item {
display: block;
padding: 0.5rem 0.5rem;
width: 100%;
white-space: nowrap; }
.dropdown__menu::after {
border-style: solid;
bottom: 100%;
content: "";
height: 0;
position: absolute;
width: 0;
right: 18px;
border-width: 0 8px 8px 8px;
border-color: #E3E3E3 transparent; }

Custom css for border-bottom

I had applied css to this thing but is there any way where i can do css of this type ?
means decreasing the bottom of the border line?
See if this help.
p {
position: relative;
z-index: 1;
width: 30px;
background: red;
padding: 10px;
color: #fff;
}
p:before {
content: "";
position: absolute;
left: 5px;
bottom: 0;
width: 80%;
border-bottom: 4px solid black;
height: 1px;
}
<p>
hello
</p>

css and :empty on table element in IE9

Can anyone figure out a fix for making the table version look like the div version in IE9?
http://jsfiddle.net/tCT9b/2/
<table class="foo"></table>
<div class="foo"></div>
div.foo {
float: right;
}
table.foo {
float: left;
}
.foo {
width: 200px;
height: 200px;
background: #fff;
border: 1px solid #999;
border-radius: 5px;
position: relative;
}
.foo:empty:before {
position: absolute;
background: #eee;
width: 50px;
height: 50px;
content: 'None';
border: 1px solid #999;
border-radius: 5px;
top: 50%;
left: 50%;
margin-left: -25px;
margin-top: -25px;
text-align: center;
display: block;
line-height: 50px;
}

Floating modal window under a button

I need show a notication modal window.. But since its a fluid layout the position changes on bigger screens.
How can i position the modal window below the link like in image. I want it in the exact position. How do i go about doing it?
This should work as a base for you.
HTML
<div class="notificaton-bar">
<div class="notice">Notification
<div>
Here is the applicable note.
</div>
</div>
</div>
CSS
.notificaton-bar {
background-color: #999999;
padding: 0 10px;
}
.notice {
position: relative;
display: inline-block;
background-color: inherit;
font-size: 1.5em;
min-width: 140px;
padding: 10px 5px;
text-align: center;
}
.notice div {
display: none;
width: 130px;
padding: 10px;
font-size: .75em;
text-align: left;
background-color: inherit;
border-radius: 10px;
position: absolute;
top: 100%;
left: 50%;
margin-left: -75px;
margin-top: 10px;
}
.notice div:before {
content: '';
display: block;
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 11px solid #999999;
position: absolute;
top: -10px;
left: 50%;
margin-left: -10px;
}
.notice:hover div {
display: block;
}

Resources