开门大吉效果

1、创建文件夹,快速生成结构。

 2、给大盒子添加宽高、背景图片、背景大小,并让其居中。

.box {
            width: 666px;
            height: 666px;
            background: url(./images/6729-16403826ce116674d831c7ad8c7379b7\(1\)\(1\).png) no-repeat;
            background-size: 666px 666px;
            margin: 0 auto;
        }

 3、设置两个子盒子背景格式

 .box .left {
            background: url(./images/df64fee3-481f-4396-aeb2-f58efea2a1c7\(1\)\(1\).png) no-repeat left 0px;
            background-size: 666px 666px;
        }
 .box .right {
            background: url(./images/df64fee3-481f-4396-aeb2-f58efea2a1c7\(1\)\(1\).png) no-repeat right 0px;
            background-size: 666px 666px;
        }

4、两个子盒子共用一张背景图,设置宽度各占一半,使用浮动,一左一右。

.box .left,
        .box .right {
            width: 333px;
            height: 666px;
        }
 float: left;
 float: right;

5、给父盒子设置溢出隐藏+移入动画(鼠标移入父盒子时子盒子生成动画效果)。

 .box:hover .left {
            transform: translateX(-100%);
        }
.box:hover .right {
            transform: translateX(100%);
        }
transition: all 1s;
overflow: hidden;

6、完整代码

<!DOCTYPE html>
<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: 666px;
            height: 666px;
            background: url(./images/6729-16403826ce116674d831c7ad8c7379b7\(1\)\(1\).png) no-repeat;
            background-size: 666px 666px;
            margin: 0 auto;
            overflow: hidden;
        }

        .box .left,
        .box .right {
            width: 333px;
            height: 666px;
            transition: all 1s;
        }

        .box .left {
            float: left;
            background: url(./images/df64fee3-481f-4396-aeb2-f58efea2a1c7\(1\)\(1\).png) no-repeat left 0px;
            background-size: 666px 666px;
        }

        .box .right {
            float: right;
            background: url(./images/df64fee3-481f-4396-aeb2-f58efea2a1c7\(1\)\(1\).png) no-repeat right 0px;
            background-size: 666px 666px;
        }

        .box:hover .left {
            transform: translateX(-100%);
        }

        .box:hover .right {
            transform: translateX(100%);
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="left">
        </div>
        <div class="right">
        </div>
    </div>
</body>

</html>

7、完成啦~

 8、图片素材

  • 8
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值