el-tree自定义文本,内容超出容器时,横向滚动条不起效

一天一个坑,这个问题搞了一个下午,岂可修,一口老血吐出来了QAQ

先上代码

主要是el-tree下的el-tree-node是个div,块级元素,导致我怎么设置,滚动条都不出来。
代码如下,将其设置为inline-block;

      // 内容溢出,设置横向滚动条
      .el-tree {
        width: 100%;
        overflow: auto;
      }

      /deep/ .el-tree > .el-tree-node {
        display: inline-block;
        min-width: 100%;
      }

html

      <div class="rightTree">
          <div class="switchText">
            {{ $t('accountBooks.table.header.switch_fast') }}
          </div>
          <el-autocomplete
            class="inline-input"
            v-model="search_value"
            :fetch-suggestions="querySearch"
            size="medium"
            :placeholder="$t('placeholder.name_enter')"
            @select="handleSelect"
            @keydown.enter.native="toSearch()"
          >
            <el-button
              size="medium"
              slot="append"
              icon="el-icon-search"
              @click.stop="clickQuery(query_result[0])"
              style="
                border-top: 1px solid #1677ff;
                color: white;
                background: #1677ff;
                border-radius: 0;
              "
            />
          </el-autocomplete>
          <div class="accTree" v-loading="treeLoading">
            <el-tree
              ref="tree"
              :data="treeData"
              node-key="code"
              default-expand-all
              :props="defaultProps"
              :expand-on-click-node="false"
              :indent="8"
              style="color: black;"
              @node-click="clickTree"
              :highlight-current="true"
              :current-node-key="currentNode"
            >
              <div
                class="custom-tree-node tree-hover"
                slot-scope="{ node, data }"
              >
                <span>
                  <i
                    v-if="data.children && data.children.length > 0"
                    class="ft-icons ft-folder-18"
                  />
                  <i
                    v-else
                    class="el-icon-document"
                    style="color: #cccccc; margin-right: 8px"
                  />
                  <span
                    style="
                      word-break: break-all;
                      white-space: nowrap;
                      padding: 3px 0px;
                    "
                  >{{ data.name }}</span>
                </span>
              </div>
            </el-tree>
          </div>
        </div>

css

 .rightTree {
    color: #717171;
    font-size: 14px;
    font-weight: 400;
    box-sizing: border-box;
    margin-left: 40px;
    padding: 0 25px;
    max-width: 320px;
    overflow-x: auto;
    background: #ffffff;
    border-radius: 4px;
    border: 1px solid #e8ecef;
    .switchText {
      margin: 38px 0 20px 0;
      font-size: 16px;
      font-family: SourceHanSansSC-Medium, SourceHanSansSC;
      font-weight: 500;
      color: #333333;
      line-height: 24px;
    }
    .accTree {
      width: auto;
      margin-top: 10px;
      text-align: left;
      // 内容溢出,设置横向滚动条
      .el-tree {
        width: 100%;
        overflow: auto;
      }

      /deep/ .el-tree > .el-tree-node {
        display: inline-block;
        min-width: 100%;
      }

      /deep/ .el-tree-node.is-current > .el-tree-node__content {
        align-self: baseline;
        background: rgba(22, 119, 255, 0.1);
        border-right: 3px solid #1677ff;
        color: #187aff;
        /deep/ .el-tree-node__expand-icon {
          color: rgb(0, 112, 255);
        }
        /deep/ .is-leaf {
          color: rgba(0, 0, 0, 0);
        }
      }
      /deep/ .el-tree-node__expand-icon {
        color: rgb(96, 98, 102);
      }
      /deep/ .is-leaf {
        color: rgba(0, 0, 0, 0);
      }
      /deep/ .el-tree-node__content {
        height: 33px;
      }
      /deep/ .el-tree-node__content:hover {
        background: rgba(22, 119, 255, 0.1);
      }
    }
  }

在这里插入图片描述

在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值