css实现简单的步骤条

深碍√TFBOYSˉ_ 2022-12-11 02:24 158阅读 0赞

效果如图:

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2h1aHVodWph_size_16_color_FFFFFF_t_70

html部分:

  1. <ul class="steps">
  2. <li>第一步 我的信息</li>
  3. <li>第二步 填写地址</li>
  4. <li>第三步 确认信息</li>
  5. <li class="active">第四步 完成提交</li>
  6. </ul>

css部分:

  1. .steps {
  2. position: relative;
  3. margin-bottom: 30px;
  4. counter-reset: step; /*创建步骤数字计数器*/
  5. }
  6. /*步骤描述*/
  7. .steps li {
  8. list-style-type: none;
  9. font-size: 12px;
  10. text-align: center;
  11. width: 25%;
  12. position: relative;
  13. float: left;
  14. }
  15. /*步骤数字*/
  16. .steps li:before {
  17. display: block;
  18. content: counter(step); /*设定计数器内容*/
  19. counter-increment: step; /*计数器值递增*/
  20. width: 32px;
  21. height: 32px;
  22. background-color: #019875;
  23. line-height: 32px;
  24. border-radius: 32px;
  25. font-size: 16px;
  26. color: #fff;
  27. text-align: center;
  28. font-weight: 700;
  29. margin: 0 auto 8px auto;
  30. }
  31. /*连接线*/
  32. .steps li ~ li:after {
  33. content: '';
  34. width: 100%;
  35. height: 2px;
  36. background-color: #019875;
  37. position: absolute;
  38. left: -50%;
  39. top: 15px;
  40. z-index: -1; /*放置在数字后面*/
  41. }
  42. /*将当前/完成步骤之前的数字及连接线变绿*/
  43. .steps li.active:before,
  44. .steps li.active:after {
  45. background-color: #019875;
  46. }
  47. /*将当前/完成步骤之后的数字及连接线变灰*/
  48. .steps li.active ~ li:before,
  49. .steps li.active ~ li:after {
  50. background-color: #777;
  51. }

发表评论

表情:
评论列表 (有 0 条评论,158人围观)

还没有评论,来说两句吧...

相关阅读

    相关 CSS实现分页

    对于搜索引擎或电子商务网站,常常将信息分页显示,这样可以减少页面大小,进而提高页面的加载速度。分页显示后,就需要通过分页导航来告诉用户要浏览的信息量,方便用户快速跳过一些...