overflow和transition

438 阅读1分钟
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 300px;
            height: 300px;
            background-color: red;
            /*超出部分隐藏 */
            /* 就算子集元素再大,给父级加上这个属性也会把多出的部分截取掉 */
            overflow:hidden;
        }
        .box .a{
            width: 500px;
            height: 200px;
            background-color: blue;
        }
        .nav{
            width: 300px;
            height: 300px;
            background-color: pink;
            /* 过度动画 */
            /* 第一个参数all是所有改变的属性都加上过度动画 */
            /* 第二个参数是过度的时间是多少 */
            transition:all 2s;
        }
        .nav:hover{
            width: 500px;
            background-color: yellow;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="a">

        </div>
    </div>
    <div class="nav">

    </div>
</body>
</html>