zoukankan      html  css  js  c++  java
  • 查看更多折叠动画(中间内容高度不确定)

    <template>
        <div class="catalogue">
            <div class="box" ref="box" :style="boxHeight">
                <div class="cont" ref="cont">
                    <li>1</li>
                    <li>1</li>
                    <li>1</li>
                    <li>1</li>
                    <li>1</li>
                    <li>1</li>
                    <li>1</li>
                    <li>1</li>
                    <li>1</li>
                    <li>1</li>
                </div>
            </div>
            <div class="btn" @click="more = !more" :class="more ? 'active' : ''">
                {{ more ? '隐藏' : '查看更多' }}<i class="el-icon-arrow-down"></i>
                <div class="shadow"></div>
            </div>
        </div>
    </template>
    
    <script>
    /**  @description:目录管理  **/
    export default {
        name: 'catalogue',
        components: {},
        data: () => ({
            more: false,
            contHeight: 0,
        }),
        computed: {
            boxHeight() {
                return {
                    height: this.more ? this.contHeight + 'px' : '200px',
                };
            },
        },
        mounted() {
            this.contHeight = this.$refs.cont.offsetHeight;
        },
    };
    </script>
    <style lang="less" scoped>
    .box {
        height: 200px;
        border: 1px solid #000;
        overflow: hidden;
        transition: all 0.2s ease;
        .cont {
            li {
                height: 50px;
            }
        }
    }
    .btn {
        height: 50px;
        text-align: center;
        line-height: 50px;
        border: 1px solid #000;
        border-top: 0;
        position: relative;
        i.el-icon-arrow-down {
            transition: all 0.2s ease;
            margin-left: @space2;
        }
        .shadow {
            height: 90px;
            width: 100%;
            position: absolute;
            top: -91px;
            background-image: linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
        }
        &.active {
            .shadow {
                display: none;
            }
            i.el-icon-arrow-down {
                transform: rotate(180deg);
            }
        }
    }
    </style>

    效果图:

     

  • 相关阅读:
    【转】java线程池ThreadPoolExecutor使用介绍
    java的类加载机制
    java面试问题分类
    ConcurrentHashMap总结
    ffmpeg对视频封装和分离
    SSM的整合
    单例模式的七种写法
    SecureCRT的快捷键
    linux下mysql常用命令
    maven操作
  • 原文地址:https://www.cnblogs.com/zhangjianhua26/p/15560305.html
Copyright © 2011-2022 走看看