Specific style on an ordered list - html

I'd like some help to integrate a design made on sketch 2 years ago ! The goal is to do a beautiful orderer list but I have difficulties to integrate the content.
This is what i've done so far :
HTML :
<div class="stepbar_block">
<ol class="stepbar_list">
<li class="stepbar_list_elem_active"> 50% </li>
<li class="stepbar_list_item">60% </li>
<li class="stepbar_list_item">70%</li>
<li class="stepbar_list_elem_current">80%</li>
<li class="stepbar_list_item">90%</li>
</ol>
</div>
CSS :
.stepbar_block {
margin: 0;
padding: 0;
counter-reset: step;
position: relative;
margin-top: 40px;
}
.stepbar_block:before {
width: 1px;
height :10px;
background-color : rgba(87,87,86,0.3);
content : '';
position : absolute;
left : 30px;
top : -4px;
}
.stepbar_block:after {
width: 1px;
height :10px;
background-color : rgba(87,87,86,0.3);
content : '';
position : absolute;
right : 30px;
top : -4px;
}
.stepbar_list li {
list-style-type: none;
float: left;
width: 20%;
height : 5px;
position: relative;
font-family: Roboto;
font-size: 10px;
line-height: 11px;
text-align: center;
color: rgba(87,87,86,0.5);
}
.stepbar_list:after {
content: '';
position: absolute;
height: 1px;
background-color: rgba(87,87,86,0.3);
left: 30px;
right: 30px;
z-index: 3;
}
.stepbar_list li:before {
content : '';
counter-increment: step;
width: 5px;
height: 5px;
border: 1px solid black;
display: block;
background-color : black;
border-radius: 40px;
text-align: center;
margin: -2px auto 10px auto;
}
.stepbar_list_item:after {
content: counter(step);
position: absolute;
top: -25px;
background-color: white;
left: 0;
right: 0;
color: rgba(87,87,86,0.5);
font-size: 10px;
line-height: 11px; text-align: center;
}
.stepbar_list_elem_active:after {
content: counter(step);
position: absolute;
top: -25px;
background-color: red;
left: 0;
right: 0;
}
.stepbar_list_elem_current:after {
content: counter(step);
position: absolute;
top: -25px;
background-color: blue;
left: 0;
right: 0;
}
https://jsfiddle.net/zawt9hL6/
However I'm able to colorise the items but not the circles, so I'd like to know what is missing because when I play with :before and :after it seems to colorize the whole list item and not a specific content
That is the result i'd like to have
It is possible to have a render like this ? Moreover it's a gradiant background on the circles..
THank you for advices

Use something like this for all.
.stepbar_list_elem_active:before {
width: 10px;
height: 10px;
background-color: #fff;
content: '';
position: absolute;
left: 0;
top: -6px;
border: 2px solid red;
border-radius: 50%;
right: 0;
margin: 0 auto;
}

You can use :before and :after pseudo elements to create that circle with gradient. First you can create just regular circle with gradient and then add one more white circle with other pseudo-element on top of the frist one.
10* {
box-sizing: border-box;
}
ul {
display: inline-flex;
list-style: none;
position: relative;
padding: 0;
margin: 0 50px;
}
ul:after {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 2px;
background: gray;
}
li {
padding: 25px;
position: relative;
}
li:after,
li.color:before {
position: absolute;
content: '';
bottom: 0;
left: 50%;
height: 10px;
width: 10px;
background: gray;
border-radius: 50%;
transform: translate(-50%, 40%);
z-index: 1;
}
li.color:after {
width: 20px;
height: 20px;
transform: translate(-50%, 9px);
}
li.color:before {
background: white;
z-index: 2;
width: 10px;
height: 10px;
}
li.yellow:after {
background: linear-gradient(to right, rgba(240,184,88,1) 0%, rgba(230,139,60,1) 38%, rgba(240,47,23,1) 71%, rgba(231,56,39,1) 100%);
}
li.blue:after {
background: linear-gradient(to right, rgba(52,163,247,1) 0%, rgba(52,163,247,1) 32%, rgba(19,100,158,1) 71%, rgba(19,100,158,1) 100%);
}
.yellow {
color: #ED4620;
}
.blue {
color: #64A3D1;
}
<ul>
<li>1</li>
<li class="color yellow">2</li>
<li class="color blue">3</li>
<li>4</li>
</ul>

Related

create specific chat bubble shape with CSS

I want to make a speech bubble shape identical to the image.
What part of the CSS shown below can be modified to make it look like the picture?
Can you help me to get the look I want?
.body{
background : linear-gradient(to bottom, #fff,red)
}
.chat {
position: relative;
width: 270px;
padding: 10px;
margin: 1em auto 50px;
text-align: center;
color: black;
background: #fff;
border: 1px solid gray;
border-radius: 30px;
}
.chat:before {
content: "";
position: absolute;
z-index: 2;
top: -2px;
left: -7px;
height: 20px;
border-left: 20px solid #E5E5EA;
border-bottom-right-radius: 16px 14px;
-webkit-transform: translate(0, -2px);
}
.chat:after {
content: "";
position: absolute;
z-index: 3;
top: -2px;
left: 4px;
width: 26px;
height: 20px;
background: white;
border-bottom-right-radius: 10px;
-webkit-transform: translate(-30px, -2px);
}
<div class="chat"></div>
We can't bring exactly as it is. I have tried to bring it near the shape.
.chat {
position:relative;
width:270px;
padding:10px;
height:50px;
margin:1em auto 50px;
text-align:center;
color:black;
background:#e5e5ea;
//border: 1px solid gray;
border-radius: 30px;
}
/* creates part of the curve */
.chat:before {
content: "";
position: absolute;
z-index: 2;
top: 7px;
left: -8px;
height: 20px;
border-left: 20px solid #E5E5EA;
border-bottom-right-radius: 16px 14px;
-webkit-transform: translate(0, -2px);
}
/* creates part of the curved pointy bit */
.chat:after {
content: "";
position: absolute;
z-index: 3;
top: 7px;
left: 4px;
width: 26px;
height: 20px;
background: white;
border-top-right-radius: 14px;
-webkit-transform: translate(-30px, -2px);
}
<div class="chat">
</div>
Here's a example based on Pure CSS speech bubbles by Nicolas Gallagher.
It uses overlapping pseudo-elements with border-radius to create the bubble's pointy curved stem. This may not be a pixel-perfect match to your mockup, but you can modify the values to improve the shape as desired.
body {
background: lightgray;
margin: 0;
}
.speech-bubble {
position: relative;
padding: 50px;
margin: 1em 20px;
text-align: center;
color: black;
background: white;
border-radius: 30px;
}
.speech-bubble:before {
content: "";
position: absolute;
z-index:-1;
left: -22px;
top: 0;
width: 40px;
border-bottom: 35px solid white;
border-top-right-radius: 25px;
}
.speech-bubble:after {
content: "";
position: absolute;
z-index:-1;
left: -28px;
top: -3px;
height: 38px;
width: 28px;
background: lightgray;
border-top-right-radius: 20px;
}
<div class="speech-bubble">Hello, world.</div>
This demo might help visualize how the stem is created:
body {
background: lightgray;
margin: 0;
}
.speech-bubble {
position: relative;
padding: 50px;
margin: 1em 20px;
text-align: center;
color: black;
background: white;
border-radius: 30px;
}
.speech-bubble:before {
content: "";
position: absolute;
z-index: -1;
left: -22px;
top: 0;
width: 40px;
border-bottom: 35px solid green;
border-top-right-radius: 25px;
}
.speech-bubble:after {
content: "";
position: absolute;
z-index: -1;
left: -28px;
top: -3px;
height: 38px;
width: 28px;
background: red;
border-top-right-radius: 20px;
}
<div class="speech-bubble">Hello, world.</div>
Also see:
How to create a curved speech bubble?
Speech bubble with arrow

How can we make this shape using CSS

How can we make this shape using CSS?
I'm able to write the below code using CSS but the shape generated output is a bit off. Can we do that using CSS?
.btn-arrow {
width: 15px;
height: 24px;
border: 2px solid red;
border-top-right-radius: 40px;
border-bottom-right-radius: 40px;
border-left: 0;
display: inline-block;
position: relative;
}
.btn-arrow:after,
.btn-arrow:before {
right: 100%;
top: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
}
.btn-arrow:after {
border-right-color: white;
border-width: 12px;
margin-top: -12px;
}
.btn-arrow:before {
border-right-color: red;
border-width: 14px;
margin-top: -14px;
}
body {
padding: 20px;
}
<div class="btn-arrow"></div>
With CSS you can achieve that.
Just create ::after and ::before pseudoelements and the main box rotate 45 degrees. You can adjust the degrees on the linear-gradient part instead of "to right" sentence.
This trick is necessary because border-image and border-radius can't live both on the same element.
You can see more about this:
Possible to use border-radius together with a border-image which has a gradient?
https://css-tricks.com/examples/GradientBorder/
.shape {
position:relative;
width: 100px;
border-radius: 100% 100% 100% 0;
height: 100px;
transform: rotate(45deg);
margin: 0 auto;
background: white;
background-clip: padding-box;
}
.shape::after {
position: absolute;
top: -8px;
bottom: -8px;
left: -8px;
right: -8px;
background: linear-gradient(to right, #fe3870, #fc5d3e);
content: '';
z-index: -1;
border-radius: 100% 100% 100% 0;
}
.shape::before {
position: absolute;
top: 8px;
bottom: 8px;
left: 8px;
right: 8px;
background: white;
content: '';
z-index: 1;
border-radius: 100% 100% 100% 0;
}
<div class="shape">
</div>
One of many possible solutions in just CSS:
This solution only requires one pseudo element.
.btn-arrow {
width: 44px;
height: 44px;
border-top-right-radius: 40px;
border-top-left-radius: 40px;
border-bottom-right-radius: 40px;
background: -webkit-linear-gradient(left, rgba(232,51,105,1) 0%,rgba(235,94,67,1) 100%); /* Chrome10-25,Safari5.1-6 */
transform:rotate(45deg);
position: relative;
}
.btn-arrow::after {
display: block;
width: 30px;
height: 30px;
border-top-right-radius: 40px;
border-top-left-radius: 40px;
border-bottom-right-radius: 40px;
background: white;
position: absolute;
content: '';
top: 7px;
left: 7px;
}
body {
padding: 20px;
}
<div class="btn-arrow"></div>
Adjust the CSS to look like this
.btn-arrow {
width: 30px;
height: 30px;
border: 2px solid red;
border-radius: 100%;
border-left: 0;
display: inline-block;
position: relative;
}
.btn-arrow:after,
.btn-arrow:before {
right: calc(100% - 6px);
top: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
}
.btn-arrow:after {
border-right-color: white;
border-width: 12px;
margin-top: -12px;
}
.btn-arrow:before {
border-right-color: red;
border-width: 14px;
margin-top: -14px;
}
body {
padding: 20px;
}

How would I go about making this border in CSS3?

How would I go about making this in CSS3/HTML5?
The Red background is the background of the div. The inner white is another div that will contain some text.
Since you already have 2 containers, you can use two pairs of pseudo elements for the corners, like this:
.outer {
width: 120px;
background: #a08;
position: relative;
padding: 30px;
}
.inner {
height: 118px;
background: #fff;
border: 1px dashed #a08;
flex: 1;
}
.outer::before, .outer::after, .inner::before, .inner::after {
content: '';
width: 20px;
height: 20px;
background: #a08;
background-clip: padding-box;
border: 1px dashed #a08;
border-radius: 50%;
position: absolute;
z-index: 1;
}
.outer::before {
top: 20px;
left: 20px;
}
.outer::after {
top: 20px;
right: 20px;
}
.inner::before {
bottom: 20px;
left: 20px;
}
.inner::after {
bottom: 20px;
right: 20px;
}
<div class="outer">
<div class="inner"></div>
</div>

Horizontal progess bar with SASS (CSS3)

I'm creating and Angular2 component to achieve the following behavior:
I have an array (strings) in the component named "stepList". This is my view:
<ul class="step">
<li class="step__item selected" *ngFor="let step of stepList">
{{step.label}}
</li>
</ul>
And this is my CSS:
.step{
display: flex;
&__item {
display: block;
padding-left: 25px;
}
}
With the current code, I have the items (names) rendered, but I don't know how to get the line with the circles underneath them.
Thanks in advance!
Use a border-bottom and a pseudo element:
.step{
display: flex;
}
.step__item {
display: block;
position: relative;
padding: 0 12px 25px;
border-bottom: 1px solid lightgray;
}
.step__item::before {
display: block;
position: absolute;
bottom: -5px;
left: calc(50% - 5px);
width: 10px;
height: 10px;
border-radius: 50%;
background: gray;
content: '';
}
<ul class="step">
<li class="step__item selected">
CATEGORIA
</li>
<li class="step__item selected">
ATTRIBUTES
</li>
</ul>
And the SCSS code:
.step{
display: flex;
&__item {
display: block;
position: relative;
padding: 0 12px 25px;
border-bottom: 1px solid lightgray;
&::before {
display: block;
position: absolute;
bottom: -5px;
left: calc(50% - 5px);
width: 10px;
height: 10px;
border-radius: 50%;
background: gray;
content: '';
}
}
}
Padding on the label with a border-bottom to get the line. Create a div with a set height and width (so, for a circle, use the same height and width), forming a square. Add a border-radius of 50% which will make it circular in shape and put the div inside the label. Position absolutely so that it appears over the border-bottom.
http://jsfiddle.net/exjxw7m6/
ul.progress-bar {
height: 300px;
list-style: none;
margin: 0;
padding: 0;
position: relative;
display: flex;
flex-direction: row;
justify-content: space-between;
overflow: hidden;
&::after {
content: "";
position: absolute;
top:5px;
left:5px;
background: #777;
height: 5px;
width: 100%;
}
li {
background: #000;
border-radius: 100px;
width: 15px;
height: 15px;
z-index: 1;
position: relative;
&.stop ~ li {
background: #777;
&::after {
height: 0;
}
}
&::after {
content: "";
position: absolute;
bottom: 0;
left: 5px;
background: #000;
width: 5px;
height: 100vh;
}
}
}
more info here: (credit) Progress bar made of solid line, with dots as steps

Timeline indicators using CSS and HTML

I am trying to recreate this image using a combination of CSS and HTML with no luck. Please advise.
Current Code:
.lens-profile-timeline {
list-style: none;
padding: 0;
margin: 60px 0 80px;
border-bottom: 8px solid #39752c;
position: relative;
}
.lens-profile-timeline li {
position: absolute;
width: 16px;
height: 16px;
border: 13px solid #39752c;
border-radius: 16px;
background: #fff;
margin-top: -10px;
margin-left: 20px;
margin-right: 20px;
}
.lens-profile-timeline time,
.lens-profile-timeline p {
left: -27px;
top: -40px;
position: absolute;
width: 70px;
text-align: center;
}
.lens-profile-timeline time {
margin-top: 70px;
font-size: 18px;
}
.lens-profile-timeline p {
margin-top: -0px;
font-size: 10px;
line-height: 1.1;
}
.lens-profile-timeline p:after {
content: "";
height: 8px;
border-left: 1px solid #39752c;
position: absolute;
bottom: -10px;
left: 35px;
}
<div class="row">
<div class="col-md-3">
</div>
<div class="col-md-6">
<ol class="lens-profile-timeline point">
<li style="left: 0;">
<time>1970</time>
</li>
<li style="left: 45%;">
<time datetime="2003-01-01">2003</time>
</li>
<li style="right: 0;">
<time>2013</time>
<p class="hidden">Current Year</p>
</li>
</ol>
</div>
<div class="col-md-3">
</div>
</div>
Above represents the current code being used to generate the image. However you will notice there are several elements which are missing.
You can do it with a combination of pseudo elements, CSS triangles and linear-gradients.
The linear-gradient(to right, #AFCB6D, #126A38); will create a mixed background color effect.
The triangles at the end can be created using CSS triangles concept using pseudo-elements.
The indicators are created with pseudo element circles as well. The indicator text can be specified within content: " " or remove the pseudo-elements and specify the text within div for better customization.
Regular text without using CSS content:
.timeline {
width: 500px;
height: 10px;
margin: 20px;
background: linear-gradient(to right, #AFCB6D, #126A38);
position: relative;
font-family: Roboto;
}
.timeline::before,
.timeline::after {
content: " ";
position: absolute;
height: 0px;
width: 0px;
top: -5px;
}
.timeline::before {
left: -20px;
border: 10px solid #AFCB6D;
border-color: transparent #AFCB6D transparent transparent;
}
.timeline::after {
right: -20px;
border: 10px solid #126A38;
border-color: transparent transparent transparent #126A38;
}
.indicators {
position: relative;
}
.indicator-1,
.indicator-2,
.indicator-3 {
border: 5px solid #AFCB6D;
background: white;
border-radius: 50%;
width: 10px;
height: 10px;
top: -5px;
position: absolute;
}
.indicator-1 {
left: 10px;
}
.indicator-2 {
border-color: #5B9951;
left: 240px;
}
.indicator-3 {
border-color: #126A38;
left: 475px;
}
.indicator-text {
position: relative;
top: 15px;
}
.indicator-1 .indicator-text {
left: -20px;
}
.indicator-2 .indicator-text {
left: -15px;
}
.indicator-3 .indicator-text {
left: -10px;
}
<div class="timeline">
<div class="indicators">
<div class="indicator-1">
<div class="indicator-text">Standard</div>
</div>
<div class="indicator-2">
<div class="indicator-text">Better</div>
</div>
<div class="indicator-3">
<div class="indicator-text">Best</div>
</div>
</div>
</div>
Titles using content property:
.timeline {
width: 500px;
height: 10px;
margin: 20px;
background: linear-gradient(to right, #AFCB6D, #126A38);
position: relative;
font-family: Roboto;
}
.timeline::before,
.timeline::after {
content: " ";
position: absolute;
height: 0px;
width: 0px;
top: -5px;
}
.timeline::before {
left: -20px;
border: 10px solid #AFCB6D;
border-color: transparent #AFCB6D transparent transparent;
}
.timeline::after {
right: -20px;
border: 10px solid #126A38;
border-color: transparent transparent transparent #126A38;
}
.indicator {
border: 5px solid #5B9951;
background: white;
border-radius: 50%;
width: 10px;
height: 10px;
margin: 0 auto;
top: -5px;
position: relative;
}
.indicator::after {
content: "\a Best";
white-space: pre;
border: 5px solid #126A38;
background: white;
border-radius: 50%;
width: 10px;
height: 10px;
top: -5px;
left: 230px;
position: absolute;
}
.indicator::before {
content: "\a Standard";
white-space: pre;
border: 5px solid #AFCB6D;
background: white;
border-radius: 50%;
width: 10px;
height: 10px;
top: -5px;
left: -240px;
position: absolute;
}
.spacer {
margin-top: 20px;
}
<div class="timeline">
<div class="indicator">
<div class="spacer"></div>Better
</div>
</div>
It's not perfect, but using CSS 3 gradients, and changing a few numbers, you can get something pretty close to your picture (minus the arrows)
I wrapped it all up in a JSBin.
Hope this helps,
Sean