去年做过一个这样的动画效果,然后今年又做了一次,今年做的时候突然发现想不起来了,抠鼻尴尬
百度了下找到了方法,在此记录下!
效果图如下
在这里插入图片描述
代码如下

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .box {
            max-height: 120px; 
            min-height: 120px; 
            overflow: hidden; 
            transition: max-height ease-out 0.2s; 
            border: 1px solid red;
            width: 200px;
        }
        .box:hover {
            max-height: 500px; 
            transition: max-height ease-in 0.2s;
        }
    </style>
</head>
<body>
    <div class="box">
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
        <p>123132123132123</p>
    </div>
</body>
</html>
Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐