简单的css3美女效果图

效果




代码


<!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>3d相册</title>

    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            background-color:tomato;
            /* 视觉效果 */
            perspective: 500px;
        }

        ul {
            margin: 100px auto;
            width: 240px;
            height: 350px;
            background-color: #fff;
            list-style: none;
            position: relative;
            transition: all 1s;
            /* 开始3d效果, 父盒子开始了3d效果之后,3d空间就被打开了,子元素就可以不用去设置该属性了; */
            transform-style: preserve-3d;
            /* 改变旋转轴的位置 */
            transform-origin: bottom;
        }

        ul:hover {
            transform: rotateX(45deg);
        }

        li {
            width: 240px;
            height: 350px;
            border: 1px solid gold;
            position: absolute;
            /* 改变旋转轴的位置为左侧 */
            transform-origin: left;
            background-color: #fff;
        }

        li:nth-child(5) {
            background: url("./girl1.jpg") left top/ 100% 100% no-repeat;
        }
        li:nth-child(4) {
            background: url("./girl2.jpg") left top/ 100% 100% no-repeat;
        }
        li:nth-child(3) {
            background: url("./girl3.jpg") left top/ 100% 100% no-repeat;
        }
        li:nth-child(2) {
            background: url("./girl4.jpg") left top/ 100% 100% no-repeat;
        }

        li:nth-child(1) {
            background: url("./girl5.jpg") left top/ 100% 100% no-repeat;
        }

        ul:hover li:nth-child(5) {
            transition: all 1s 1s;
            transform: rotateY(-170deg);
        }

        ul:hover li:nth-child(4) {
            transition: all 1s 2s;
            transform: rotateY(-150deg);
        }

        ul:hover li:nth-child(3) {
            transition: all 1s 3s;

            transform: rotateY(-130deg);
        }

        ul:hover li:nth-child(2) {
            transition: all 1s 4s;
            transform: rotateY(-110deg);
        }
    </style>

</head>
<body>
    <ul>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
    </ul>
</body>
</html>

总结

    1. 如果想要开启3d效果,那么需要给该元素设置tansform-style: preserve-3d;
    2. 如果想要有近大远小的效果, 就需要给其父盒子设置 perspective: 500px;
    3. 如果我们想要改变旋转轴的位置, 那么就需要设置transform-origin

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值