当前位置:   article > 正文

Vue手写模拟步骤条

Vue手写模拟步骤条
效果图:

如果要使用element的步骤条就需要强行修改样式,参考之前的那篇步骤条。这里我采用手写div

代码:

思路是给最外层的div一个左边框,给里面的step-item设置左边框为图片,通过定位来移动。

  1. <div class="mock-step"> 最外层的div
  2. <div class="step-item">
  3. <span class="item-date">2024-01-21</span>
  4. <span class="item-price">¥1,099,000</span>
  5. </div>
  6. <div class="step-item">
  7. <span class="item-date">2024-01-21</span>
  8. <span class="item-price">¥1,099,000</span>
  9. </div>
  10. <div class="step-item">
  11. <span class="item-date">2024-01-21</span>
  12. <span class="item-price">¥1,099,000</span>
  13. </div>
  14. </div>
 样式:

第一步中其实还有个属性叫 background-position也可以移动背景图片,但是我图定位方便;

其他样式属性我删掉了,只留了关键点;

  1. .mock-step {
  2. border-left: 1px solid rgb(238, 238, 238);
  3. .step-item {
  4. position: relative; 移动div
  5. left: -4px;
  6. background-image: url('../../assets/insure/step-icon.png'); 圈圈背景图
  7. background-repeat: no-repeat;
  8. background-size: 8px 8px;
  9. height: 33px;
  10. display: flex;
  11. justify-content: space-between;
  12. .item-date {
  13. position: relative; 自行修改
  14. top: -4px;
  15. }
  16. .item-price {
  17. position: relative;
  18. top: -4px;
  19. }
  20. }
  21. }
  22. .mock-step:last-child .step-item:last-child {
  23. height: auto !important;
  24. }
方法二:

去掉了用图片做边框。直接将图片放在里面。用grid定位

  1. 修改版本
  2. .step-item {
  3. position: relative;
  4. left: -4px;
  5. // background-image: url('../../assets/insure/step-icon.png');
  6. // background-position: left;
  7. background-repeat: no-repeat;
  8. background-size: 8px 8px;
  9. // padding-left: 14px;
  10. padding-right: 12px;
  11. height: 33px;
  12. // display: flex;
  13. // justify-content: space-between;
  14. display: grid;
  15. grid-template-columns: repeat(3, 15px 60% 35%);
  16. }
总结: 

但是这样会导致最后一个会有一点点超出,虽然做了处理还是比较明显,不知道优化了。有没有建议哦? 

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/258669
推荐阅读
相关标签
  

闽ICP备14008679号