当前位置:   article > 正文

css class 多种规则判断样式_css 样式加判断

css 样式加判断

需求

商品分类选择变量 上下的分类需要添加圆角 这个就设计到多个分类的判断 

解决方法

在class里面多写些判断 判断上下的分类 做成圆角即可

代码

  1. <!-- html -->
  2. <view v-for="(item,index) in tabbar" :key="index" class="u-tab-item" :class="`${current == index ? 'u-tab-item-active' : ''}
  3. ${current > 0 && current - 1 == index ? 'radius-bottom' : ''}
  4. ${current < tabbar.length - 1 && current + 1 == index ? 'radius-top' : ''}`"
  5. @tap.stop="swichMenu(index)">
  6. <text class="u-line-1">{{item.name}}</text>
  7. </view>
  8. // css
  9. .u-tab-item-active {
  10. position: relative;
  11. color: #000;
  12. font-size: 30rpx;
  13. font-weight: 600;
  14. background: #fff;
  15. }
  16. .u-tab-item-active::before {
  17. content: "";
  18. position: absolute;
  19. border-left: 6px solid $u-primary;
  20. border-radius: 15rpx;
  21. height: 32rpx;
  22. left: 0;
  23. top: 39rpx;
  24. }
  25. .radius-top {
  26. border-top-right-radius: 30rpx;
  27. }
  28. .radius-bottom {
  29. border-bottom-right-radius: 30rpx;
  30. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/代码探险家/article/detail/889134
推荐阅读
相关标签
  

闽ICP备14008679号