html - 如何创建具有不同圆环颜色的有序列表

标签 html css

我正在使用有序列表显示结果。现在我想在数字中添加一个圆圈,颜色从绿色变为红色。使用是第一个结果是优先级,其他的次之。所以颜色渐变从绿色变为红色。

.listAddress li {
    padding-top: 15px;
    padding-bottom: 15px;
    display: list-item;
    padding: 10px 10px;
    color: #252424;
    font-size: 12px;
     width: auto;
    font-style: normal;
    text-transform: uppercase;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
<ol class="listAddress">
<li>365 W Northwest Hwy, Palatine, IL 60067, USA</li>
<li>365 W Northwest Hwy, Palatine, IL 60067, USA</li>
<li>365 W Northwest Hwy, Palatine, IL 60067, USA</li>
</ol>

最佳答案

看看这是否有帮助。

jsFiddle

body { background: white; }
.listAddress {
  padding-left: 0;
  position: relative;
}
.listAddress:before {
  content: "";
  position: absolute;
  z-index: -2;
  left: 0;
  top: 0;
  bottom: 0;
  width: 20px;
  background: linear-gradient(to bottom, green, red);
}
.listAddress li {
  counter-increment: step-counter;
  list-style: none;
  padding-bottom: 20px;
  position: relative;
  padding-left: 25px;
  overflow: hidden;
}
.listAddress li:before {
  content: counter(step-counter);
  margin-right: 5px;
  box-shadow: 0 0 0 100px white;
  color: white;
  border-radius: 50%;
  position: absolute;
  z-index: -1;
  left: 0;
  top: 0;
  text-align: center;
  width: 20px;
  height: 20px;
}
<ol class="listAddress">
  <li>365 W Northwest Hwy, Palatine, IL 60067, USA</li>
  <li>365 W Northwest Hwy, Palatine, IL 60067, USA</li>
  <li>365 W Northwest Hwy, Palatine, IL 60067, USA</li>
  <li>365 W Northwest Hwy, Palatine, IL 60067, USA</li>
  <li>365 W Northwest Hwy, Palatine, IL 60067, USA</li>
</ol>

关于html - 如何创建具有不同圆环颜色的有序列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41351197/

相关文章:

javascript - 使用 JavaScript 变量设置选中的单选按钮

javascript - 无法获取图像高度,改为获取naturalHeight

javascript - 创建一个高度等于剩余可用空间的 div

jquery - 如何使用jquery更改元素的CSS

javascript - 滚动标题更改

html - 为什么不为 IE7+ 使用 col-sm-6

jquery - 防止元素在圆形 CSS3 动画中自行旋转

css - jquery ui 选项卡上的默认光标

html - CSS/HTML : Create a glowing border around an Input Field

css - 在 Safari 6 中使用 CSS3 灰度滤镜进行对比度重载