设置不定长border-bottom

添加链接描述需求:给表头和表格底部下方添加变长border-bottom
如图
在这里插入图片描述
解决方法:
伪元素,设置width

  • width不能固定,故在css中使用js变量,根据表头长度来计算width
    • 先在表头及表格页面处加上:style=“cssVar”;
    • 在计算属性中用表头的个数*单个表格的长度,最终得到的就是变长的border-bottom

Html:

  <div class="schema-list-title" >
          <span v-for="item in titleList" :key="item" class="schema-list-field" :style="cssVar">
            <el-tooltip
              class="item"
              effect="dark"
              :content="typeof item === 'object' ? item : JSON.stringify(item)"
              placement="top"
            >
              <span class="schema-list-field" >{{ item }}</span>
            </el-tooltip>
          </span>
        </div>
        <div class="schema-list-content" >
          <div
            v-for="(item, index) in currentPageData"
            :key="index"
            class="schema-list-row"
            :style="cssVar"
          >
            <p v-for="(i, a) in item" :key="a" class="schema-list-field">
              <el-tooltip
                effect="dark"
                :content="i.toString()"
                placement="top"
                v-if="i"
              >
                <span class="schema-list-field">{{ i }}</span>
              </el-tooltip>
              <span v-else>--</span>
            </p>
          </div>
        </div>
 computed:{
    cssVar(){
        return{'--listLength':this.titleList.length * 150 +'px'}
    }
  }
 .schema-list {
    padding: 20px;
    overflow-x: auto;

    .schema-list-title,
    .schema-list-row {
      height: 45px;
      line-height: 45px;
      white-space: nowrap;
      align-content: center;
      position: relative;
  
      ::after {
        content: " ";
        position: absolute;
        width:  var(--listLength);
        height: 1px;
        bottom: 0px;
        left: 0;
        top:auto;
        border-bottom: 0.01rem solid rgba(227, 229, 237, 5);
      }
  }
}

vue2在css中使用js变量

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值