简体   繁体   中英

Specific style on an ordered list

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> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM