css 骚操作

150 阅读1分钟
图片按比例展示
 width: 100%;
 height: auto;
 aspect-ratio: 1.6;
elementui table表格 数据空的情况下默认展示--
.el-table tbody td .cell:empty::after { content: '--'; }
横向滚动 点击某个子元素 让其滚动到中间位置
    btnClick(event) {
      const item = event.target;
      const itemLeft = item.offsetLeft;
      const scrollLeft = this.$refs.scrollDiv.scrollLeft;
      const containerWidth = this.$refs.scrollDiv.clientWidth;
      const itemWidth = item.clientWidth;

      const center = scrollLeft + containerWidth / 2;
      const left = itemLeft - containerWidth / 2 - itemWidth / 2;

      this.$refs.scrollDiv.scroll({
        left: left,
        behavior: 'smooth'
      });
    },