I am not sure why the position for the circle and container for the left side can't fix like the right side. When I resize the screen, the circle of the right container can still remind in the middle of the line but the left side cant. Does anyone know what is the error?
.timeline {
position: relative;
max-width: 100%;
margin: 0 auto;
}
.timeline::after {
content: '';
position: absolute;
width: 0.375em;
background-color: #D5D5D5;
top: 0;
bottom: 0;
left: 50%;
margin-left: -0.1875em;
}
.container2 {
padding: 0.625em 2.5em;
position: relative;
background-color: inherit;
width: 40%;
}
.container2::after {
content: '';
position: absolute;
width: 1.5625em;
height: 1.5625em;
right: -1.0625em;
background-color: white;
border: 0.25em solid #86B5D0;
top: 0.9375em;
border-radius: 50%;
z-index: 1;
}
.left {
left: 2.2%;
}
.right {
left: 50%;
}
.right::after {
left: -1em;
}
.left::before {
content: " ";
height: 0;
position: absolute;
top: 1.375em;
width: 0;
z-index: 1;
right: 1.875em;
border: medium solid #2D336A;
border-width: 0.625em 0 0.625em 0.625em;
border-color: transparent transparent transparent #2D336A;
}
.right::before {
content: " ";
height: 0;
position: absolute;
top: 1.375em;
width: 0;
z-index: 1;
left: 1.875em;
border: medium solid #2D336A;
border-width: 0.625em 0.625em 0.625em 0;
border-color: transparent #2D336A transparent transparent;
}
.content {
padding: 1.25em 1.875em;
background-color: #2D336A;
position: relative;
border-radius: 0.375em;
}
#media screen and (max-width: 40%) {
/* Place the timelime to the left */
.timeline::after {
left: 1.9375em;
}
/* Full-width containers */
.container2 {
width: 100%;
padding-left: 4.375em;
padding-right: 1.5625em;
}
/* Make sure that all arrows are pointing leftwards */
.container2::before {
left: 3.75em;
border: medium solid white;
border-width: 0.625em 0.625em 0.625em 0;
border-color: transparent white transparent transparent;
}
/* Make sure all circles are at the same spot */
.left::after,
.right::after {
left: 0.9375em;
}
/* Make all right containers behave like the left ones */
.right {
left: 0%;
}
}
<div class="timeline">
<div class="container2 left">
<div class="content">
<font class="titleText1">1</font><br><br> ABC
</div>
</div>
<div class="container2 right">
<div class="content">
<font class="titleText">2</font><br><br> ABC
</div>
</div>
</div>
Your .container2 elements are positioned with relative so that they remain in a vertical flow. When you position the .right one with left: 50%, it shifts it exactly over the timeline: great!
Now you'd like to do the opposite for the .left one, which would be right: 50%. But that won't work as it's not positioned in absolute, so it will shift from its natural position within the page flow.
Fix this by setting it float: right so it starts from the far right and ends up spot-on the timeline. But it breaks the flow again.
So add clear: both to .container2 to restore vertical flow and you're finally there.
One of the very rare instances where float can actually help!
.timeline {
position: relative;
max-width: 100%;
margin: 0 auto;
}
.timeline::after {
content: '';
position: absolute;
width: 0.375em;
background-color: #D5D5D5;
top: 0;
bottom: 0;
left: 50%;
margin-left: -0.1875em;
}
.container2 {
clear: both; /* Add this */
padding: 0.625em 2.5em;
position: relative;
background-color: inherit;
width: 40%;
}
.container2::after {
content: '';
position: absolute;
width: 1.5625em;
height: 1.5625em;
right: -1.0625em;
background-color: white;
border: 0.25em solid #86B5D0;
top: 0.9375em;
border-radius: 50%;
z-index: 1;
}
.left {
float: right; /* Add this */
right: 50%; /* Change this */
}
.right {
left: 50%;
}
.right::after {
left: -1em;
}
.left::before {
content: " ";
height: 0;
position: absolute;
top: 1.375em;
width: 0;
z-index: 1;
right: 1.875em;
border: medium solid #2D336A;
border-width: 0.625em 0 0.625em 0.625em;
border-color: transparent transparent transparent #2D336A;
}
.right::before {
content: " ";
height: 0;
position: absolute;
top: 1.375em;
width: 0;
z-index: 1;
left: 1.875em;
border: medium solid #2D336A;
border-width: 0.625em 0.625em 0.625em 0;
border-color: transparent #2D336A transparent transparent;
}
.content {
padding: 1.25em 1.875em;
background-color: #2D336A;
position: relative;
border-radius: 0.375em;
}
#media screen and (max-width: 40%) {
/* Place the timelime to the left */
.timeline::after {
left: 1.9375em;
}
/* Full-width containers */
.container2 {
width: 100%;
padding-left: 4.375em;
padding-right: 1.5625em;
}
/* Make sure that all arrows are pointing leftwards */
.container2::before {
left: 3.75em;
border: medium solid white;
border-width: 0.625em 0.625em 0.625em 0;
border-color: transparent white transparent transparent;
}
/* Make sure all circles are at the same spot */
.left::after,
.right::after {
left: 0.9375em;
}
/* Make all right containers behave like the left ones */
.right {
left: 0%;
}
}
<div class="timeline">
<div class="container2 left">
<div class="content">
<font class="titleText1">1</font><br><br> ABC
</div>
</div>
<div class="container2 right">
<div class="content">
<font class="titleText">2</font><br><br> ABC
</div>
</div>
</div>
Related
How to place a vertical line between two div elements?
.flex-container {
display: -webkit-flex;
margin: 0 auto;
text-align: center;
}
.flex-container .column {
width: 320px;
text-align: center;
}
.vr {
border-left: 2px dotted black;
width: 2px;
margin: 0px 5px 0px 5px;
height: 200px;
}
<div>
<div class="flex-container mt-3 d-flex justify-content-center align-items-center">
<div class="column">Karvat group was established in Mumbai.</div>
<div class="vr "></div>
<div class="column2 bg-alt box arrow-left ml-15 "> 1952</div>
</div>
</div>
Rough way of getting this done.
HTML
<div class="timeline">
<div class="container left">
<div class="content">
<h2>2017</h2>
<p>Lorem ipsum..</p>
</div>
</div>
<div class="container right">
<div class="content">
<h2>2016</h2>
<p>Lorem ipsum..</p>
</div>
</div>
</div>
CSS
* {
box-sizing: border-box;
}
/* Set a background color */
body {
background-color: #474e5d;
font-family: Helvetica, sans-serif;
}
/* The actual timeline (the vertical ruler) */
.timeline {
position: relative;
max-width: 1200px;
margin: 0 auto;
}
/* The actual timeline (the vertical ruler) */
.timeline::after {
content: '';
position: absolute;
width: 6px;
background-color: white;
top: 0;
bottom: 0;
left: 50%;
margin-left: -3px;
}
/* Container around content */
.container {
padding: 10px 40px;
position: relative;
background-color: inherit;
width: 50%;
}
/* The circles on the timeline */
.container::after {
content: '';
position: absolute;
width: 25px;
height: 25px;
right: -17px;
background-color: white;
border: 4px solid #FF9F55;
top: 15px;
border-radius: 50%;
z-index: 1;
}
/* Place the container to the left */
.left {
left: 0;
}
/* Place the container to the right */
.right {
left: 50%;
}
/* Add arrows to the left container (pointing right) */
.left::before {
content: " ";
height: 0;
position: absolute;
top: 22px;
width: 0;
z-index: 1;
right: 30px;
border: medium solid white;
border-width: 10px 0 10px 10px;
border-color: transparent transparent transparent white;
}
/* Add arrows to the right container (pointing left) */
.right::before {
content: " ";
height: 0;
position: absolute;
top: 22px;
width: 0;
z-index: 1;
left: 30px;
border: medium solid white;
border-width: 10px 10px 10px 0;
border-color: transparent white transparent transparent;
}
/* Fix the circle for containers on the right side */
.right::after {
left: -16px;
}
/* The actual content */
.content {
padding: 20px 30px;
background-color: white;
position: relative;
border-radius: 6px;
}
/* Media queries - Responsive timeline on screens less than 600px wide */
#media screen and (max-width: 600px) {
/* Place the timelime to the left */
.timeline::after {
left: 31px;
}
/* Full-width containers */
.container {
width: 100%;
padding-left: 70px;
padding-right: 25px;
}
/* Make sure that all arrows are pointing leftwards */
.container::before {
left: 60px;
border: medium solid white;
border-width: 10px 10px 10px 0;
border-color: transparent white transparent transparent;
}
/* Make sure all circles are at the same spot */
.left::after, .right::after {
left: 15px;
}
/* Make all right containers behave like the left ones */
.right {
left: 0%;
}
}
Output:
Here is the sample code for it, You can also take some help from online codepen's https://codepen.io/havardob/pen/dyKoOjX
.stepper{
height: 400px;
width: 1px;
border-right: 2px dashed black;
position: relative;
}
.stepper:before,
.stepper:after
{
content: "";
position: absolute;
width: 10px;
height: 10px;
right: -7px;
border-radius: 50%;
border: 1px solid black;
background: #fff;
}
.stepper:after{
top: 50px;
}
<div class="stepper">
</div>
I am trying to teach myself how ot build a timeline and add images. I found this on W3. I want to add images left / right of each text-container displaying what is writte in the text.
I experimented around a lot trying to make it work but I dont completely understand. Also there are some parts within this code I dont completely understand yet. It would be helpful I think, if you could break it down into pieces are explain a little on what each code of line does. But my main problem is to add images next to (left or right) the text-containers.
Thank you.
* {
box-sizing: border-box;
}
body {
background-color: #474e5d;
font-family: Helvetica, sans-serif;
}
.timeline {
position: relative;
max-width: 1200px;
margin: 0 auto;
}
.timeline::after {
content: '';
position: absolute;
width: 6px;
background-color: white;
top: 0;
bottom: 0;
left: 50%;
margin-left: -3px;
}
.container {
padding: 10px 40px;
position: relative;
background-color: inherit;
width: 50%;
}
.container::after {
content: '';
position: absolute;
width: 25px;
height: 25px;
right: -17px;
background-color: white;
border: 4px solid #FF9F55;
top: 15px;
border-radius: 50%;
z-index: 1;
}
.left {
left: 0;
}
.right {
left: 50%;
}
.left::before {
content: " ";
height: 0;
position: absolute;
top: 22px;
width: 0;
z-index: 1;
right: 30px;
border: medium solid white;
border-width: 10px 0 10px 10px;
border-color: transparent transparent transparent white;
}
.right::before {
content: " ";
height: 0;
position: absolute;
top: 22px;
width: 0;
z-index: 1;
left: 30px;
border: medium solid white;
border-width: 10px 10px 10px 0;
border-color: transparent white transparent transparent;
}
.right::after {
left: -16px;
}
.content {
padding: 20px 30px;
background-color: white;
position: relative;
border-radius: 6px;
}
<div class="timeline">
<div class="container left">
<div class="content">
<h2>2017</h2>
<p>Lorem ipsum..</p>
</div>
</div>
<div class="container right">
<div class="content">
<h2>2016</h2>
<p>Lorem ipsum..</p>
</div>
</div>
</div>
You can add the image to existing container using <img> tag.
<div class="container left">
<div class="content">
<h2>2017</h2>
<p>Lorem ipsum..</p>
</div>
<img src="https://placehold.it/200x200" /> <!-- image tag inside the container -->
</div>
I added the below additional CSS and used CSS flexbox layout.
/* Newly added CSS begin*/
.container {
display: flex; /*this makes the container flexbox layout*/
}
.container.left .content {
order: 2; /* order changes the content order within container */
margin-left: auto; /* pushes the left content box to extreme left */
}
.container.right .content {
margin-right: auto;
}
.container img {
margin: 0 20px;
}
/* Newly added CSS ends */
Updated code is below:
* {
box-sizing: border-box;
}
body {
background-color: #474e5d;
font-family: Helvetica, sans-serif;
}
/* Newly added CSS begin*/
.container {
display: flex;
}
.container.left .content {
order: 2;
margin-left: auto;
}
.container.right .content {
margin-right: auto;
}
.container img {
margin: 0 20px;
}
/* Newly added CSS ends */
.timeline {
position: relative;
max-width: 1200px;
margin: 0 auto;
}
.timeline::after {
content: '';
position: absolute;
width: 6px;
background-color: white;
top: 0;
bottom: 0;
left: 50%;
margin-left: -3px;
}
.container {
padding: 10px 40px;
position: relative;
background-color: inherit;
width: 50%;
}
.container::after {
content: '';
position: absolute;
width: 25px;
height: 25px;
right: -17px;
background-color: white;
border: 4px solid #FF9F55;
top: 15px;
border-radius: 50%;
z-index: 1;
}
.left {
left: 0;
}
.right {
left: 50%;
}
.left::before {
content: " ";
height: 0;
position: absolute;
top: 22px;
width: 0;
z-index: 1;
right: 30px;
border: medium solid white;
border-width: 10px 0 10px 10px;
border-color: transparent transparent transparent white;
}
.right::before {
content: " ";
height: 0;
position: absolute;
top: 22px;
width: 0;
z-index: 1;
left: 30px;
border: medium solid white;
border-width: 10px 10px 10px 0;
border-color: transparent white transparent transparent;
}
.right::after {
left: -16px;
}
.content {
padding: 20px 30px;
background-color: white;
position: relative;
border-radius: 6px;
}
<div class="timeline">
<div class="container left">
<div class="content">
<h2>2017</h2>
<p>Lorem ipsum..</p>
</div>
<img src="http://placehold.it/200x200" />
</div>
<div class="container right">
<div class="content">
<h2>2016</h2>
<p>Lorem ipsum..</p>
</div>
<img src="http://placehold.it/200x200" />
</div>
</div>
Fiddle
Updated Fiddle with Adjacent images
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;
}
I want to remove the first line from the CSS timeline I created, I just want the timeline circle to show up first not to have a line before it. I also want to style each dot different color, how can I do both these?
I have tried to add a class to one of the timeline containers called .not_complete but it doesnt change the color of the circle of the timeline.
/* The actual timeline (the vertical ruler) */
.timelinex {
position: relative;
max-width: 1200px;
margin: 0 auto;
padding-bottom: 5em;
}
/* The actual timeline (the vertical ruler) */
.timelinex:before {
content: '';
position: absolute;
width: 0px;
background-color: #fff;
top: auto;
bottom: 0;
left: 50%;
margin-left: -3px;
}
.timelinex::after {
content: '';
position: absolute;
width: 4px;
background-color: #e3e3e3;
top: 0;
bottom: 0;
left: 50%;
margin-left: -3px;
}
/* Container around content */
.containerx {
padding: 10px 40px;
position: relative;
background-color: inherit;
width: 50%;
}
/* The circles on the timeline */
.containerx::after {
content: '';
position: absolute;
width: 12px;
height: 12px;
right: -5px;
background-color: #e3e3e3;
top: 15px;
border-radius: 50%;
z-index: 1;
}
.containerx::after .not_complete {
background-color: #e3e3e3 !important;
}
/* Place the container to the left */
.leftx {
left: 0;
}
/* Place the container to the right */
.rightx {
left: 50%;
}
/* Fix the circle for containers on the right side */
.rightx::after {
left: -7px;
}
/* The actual content */
.contentx {
padding: 2px 3px;
position: relative;
border-radius: 6px;
}
<div class="timelinex">
<div class="containerx leftx not_complete">
<div class="contentx">
<p>
<img src="assets/img/therapist1.jpg" style="border-radius: 0.5em;border-top-left-radius: 120px; border-bottom-right-radius: 120px">
</p>
<h5 style="color:#999;font-style: 0.5em"> DAY 1 </h5>
<div> Test Timeline Step 1</div>
</div>
</div>
</div>
The selector here is invalid:
.containerx::after .not_complete {
It would select the child of the ::after pseudo element. You need to use:
.containerx.not_complete::after {
The above selector selects any element's ::after pseudo element, with the classes containerx and not_complete. So kindly replace your code with:
.containerx.not_complete::after {
background-color: #e3e3e3 !important;
}
Hope this solves your issue.
Complete Snippet
/* The actual timeline (the vertical ruler) */
.timelinex {
position: relative;
max-width: 1200px;
margin: 0 auto;
padding-bottom: 5em;
}
/* The actual timeline (the vertical ruler) */
.timelinex:before {
content: '';
position: absolute;
width: 0px;
background-color: #fff;
top: auto;
bottom: 0;
left: 50%;
margin-left: -3px;
}
.timelinex::after {
content: '';
position: absolute;
width: 4px;
background-color: #e3e3e3;
top: 0;
bottom: 0;
left: 50%;
margin-left: -3px;
}
/* Container around content */
.containerx {
padding: 10px 40px;
position: relative;
background-color: inherit;
width: 50%;
}
/* The circles on the timeline */
.containerx::after {
content: '';
position: absolute;
width: 12px;
height: 12px;
right: -5px;
background-color: #e3e3e3;
top: 15px;
border-radius: 50%;
z-index: 1;
}
.containerx.not_complete::after {
background-color: #e3e3e3 !important;
}
/* Place the container to the left */
.leftx {
left: 0;
}
/* Place the container to the right */
.rightx {
left: 50%;
}
/* Fix the circle for containers on the right side */
.rightx::after {
left: -7px;
}
/* The actual content */
.contentx {
padding: 2px 3px;
position: relative;
border-radius: 6px;
}
<div class="timelinex" >
<div class="containerx leftx not_complete">
<div class="contentx">
<p><img src="assets/img/therapist1.jpg" style="border-radius: 0.5em;border-top-left-radius: 120px; border-bottom-right-radius: 120px"></p>
<h5 style="color:#999;font-style: 0.5em"> DAY 1 </h5>
<div> Test Timeline Step 1</div>
</div>
</div>
</div>
Update: For Even / Odd Styling and First Child.
To create odd and even styling, you need to use :nth-child() selector. An example of having it blue and red is here:
li {
display: block;
width: 200px;
padding: 10px;
color: #fff;
}
li:nth-child(odd) {
background: #00f;
}
li:nth-child(even) {
background: #f00;
}
li:first-child {
background: #000;
font-weight: bold;
}
<ul>
<li>First Child</li>
<li>Even</li>
<li>Odd</li>
<li>Even</li>
<li>Odd</li>
</ul>
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>