css绘制多行多列的按钮不同状态渲染

css绘制多行多列的按钮不同状态渲染

ui给的图

在这里插入图片描述

最终实现效果

在这里插入图片描述

废话少说,直接上代码

<template>
  <div class="status-containt">
    <div class="title">
      <ul v-for="num in 2" :key="num">
        <li v-for="(item,index) in titleList" :key="index">
          {{ item }}
        </li>
      </ul>
    </div>
    <div class="status">
      <div v-for="(item) in dataArr" :key="item.name" class="status-bar">
        <ul :class="{'bartype':true,'green':item.status === 1, 'red':item.status === 2,'yellow':item.status === 3,'light-yellow':item.status === 4}">
          <li
            v-for="count in 4"
            :key="count"
          />
        </ul>
        <span>{{ item.stationName }}</span>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'DaHealthChart',
  props: {
    options: {
      type: Array,
      default: () => {}
    }
  },
  data() {
    return {
      dataArr: [{ stationName: '01', status: 2 }, { stationName: '02', status: 2 }, { stationName: '03', status: 1 }, { stationName: '04', status: 4 }, { stationName: '05', status: 3 }, { stationName: '06', status: 2 }, { stationName: '07', status: 3 }, { stationName: '08', status: 3 }, { stationName: '09', status: 3 }, { stationName: '10', status: 3 }, { stationName: '11', status: 2 }, { stationName: '12', status: 1 }, { stationName: '13', status: 1 }, { stationName: '14', status: 3 }, { stationName: '15', status: 4 }, { stationName: '16', status: 3 }, { stationName: '17', status: 1 }, { stationName: '18', status: 2 }, { stationName: '19', status: 1 }, { stationName: '20', status: 3 }, { stationName: '21', status: 3 }, { stationName: '22', status: 2 }],
      titleList: ['正常', '较差', '差', '恶劣', '管段']
    }
  }
}
</script>
.status-containt {
    width: 100%;
    height: 50%;
    display: flex;
    flex-flow: row nowrap;
    padding-left: 16px;
    overflow: hidden;
    .title {
    height: 100%;
    width: 10%;
    display: flex;
    flex-flow: column nowrap;
    align-items: center;
    justify-content: space-around;
    ul {
        height: 30%;
        li{
        height: 26px;
        line-height: 34px;
        text-align: right;
        font-size: 12px;
            &:nth-child(1){
                color: #06FF00;
            }
            &:nth-child(2){
                color: #DDE674;
            }
            &:nth-child(3){
                color: #FAAD52;
            }
            &:nth-child(4){
                color: #FF4444;
            }
            &:nth-child(5){
                color: #AEBFC8;
            }
        }
    }
    }
    .status {
        height: 100%;
        width: 80%;
        display: flex;
        padding: 5px;
        flex-flow: row wrap;
        justify-content: space-around;
        align-items: center;
        .status-bar {
            width: 7%;
            height: 30%;
            margin: 2px;
            display: flex;
            flex-flow: column nowrap;
            align-items: center;
            &:hover,&:active {
              color: #28FFFC;
            }
            .bartype {
                width: 100%;
                height: 100%;
                display: flex;
                flex-flow: column nowrap;
                align-items: center;
                justify-content: space-around;
                background: url(/station/initbg.png) no-repeat;
                background-size: cover;
                &:hover,&:active{
                    background: url(/station/activebg.png) no-repeat;
                    background-size: contain;
                }
            }
            li{
                  width: 10px;
                  height: 10px;
                  border-radius: 50%;
                  background-color: rgba(255,255,255,0.3);
            }
            .green{
                li:nth-child(1){
                  background-color:#06FF00;
                  box-shadow: 0 0 5px #06FF00;
                }
            }
            .red{
                li:nth-child(4){
                  background-color:#FF5353;
                  box-shadow: 0 0 5px #FF5353;
                }
            }
            .yellow {
                li:nth-child(3){
                  background-color:#FAAD52;
                  box-shadow: 0 0 5px #FAAD52;
                }
            }
            .light-yellow{
                li:nth-child(2){
                  background-color:#F0FF52;
                  box-shadow: 0 0 5px #F0FF52;
                }
            }
        }
    }
}

重点标注

在每个竖条的ul标签上条件判断类,状态1就是第1个li背景绿色,其余的li背景灰色

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值