0
点赞
收藏
分享

微信扫一扫

Css3——3D两面翻转盒子案例

吓死我了_1799 2022-05-03 阅读 67
css33dcss

思路:
html结构:
box父盒子里面包含前后两个子盒子
box是翻转的盒子 qian是前面的盒子,hou是后面的盒子

css样式:
box指定大小,添加3d呈现
hou盒子要沿着Y轴旋转180度
最后鼠标经过box沿着y轴旋转180度

HTML:

<div class="box">
        <div class="qian">我是正面</div>
        <div class="hou">我是反面</div>
    </div>

CSS:

 body{
            perspective: 400px;
        }
        .box {
            position: relative;
            width: 300px;
            height: 300px;
            margin: 100px auto;
            transition: all .5s;
            / 让背面的紫色盒子保留立体空间  给父级添加/
            transform-style: preserve-3d;
        }
        .box:hover{
            transform: rotateY(180deg);
        }
        .qian,
        .hou {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border-radius: 50%;
            font-size: 30px;
            color: #fff;
            text-align: center;
            line-height: 300px;


        }

        .qian {

            background-color: pink;
            / 提升权限/
            z-index: 1;
        }

        .hou {
            background-color: purple;
            /背靠背旋转 /
            transform: rotateY(180deg);
        }

效果:
请添加图片描述

举报

相关推荐

0 条评论