前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >前端特效学习4

前端特效学习4

作者头像
用户7162790
发布2022-03-23 14:34:47
2180
发布2022-03-23 14:34:47
举报
文章被收录于专栏:森屿暖树森屿暖树

效果图

demo
demo

HTML代码

代码语言:javascript
复制
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>demo</title>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
</head>
<body>
    <div class="container">
        <div class="wrap">
            <div class="cube">
                <div class="out-front">
                    <img src="img/t1.jpg">
                </div>
                <div class="out-back">
                    <img src="img/t1.jpg">
                </div>
                <div class="out-left">
                    <img src="img/t1.jpg">
                </div>
                <div class="out-right">
                    <img src="img/t1.jpg">
                </div>
                <div class="out-top">
                    <img src="img/t1.jpg">
                </div>
                <div class="out-bottom">
                    <img src="img/t1.jpg">
                </div>

                <span class="in-front">
                    <img src="img/t1.jpg">
                </span>
                <span class="in-back">
                    <img src="img/t1.jpg">
                </span>
                <span class="in-left">
                    <img src="img/t1.jpg">
                </span>
                <span class="in-right">
                    <img src="img/t1.jpg">
                </span>
                <span class="in-top">
                    <img src="img/t1.jpg">
                </span>
                <span class="in-bottom">
                    <img src="img/t1.jpg">
                </span>
            </div>
        </div>
    </div>
    <script>
        $(function() {
            var outWidth = $(" .container .wrap .cube div").width();
            var inWidth = $(" .container .wrap .cube span").width();
            var inOffset = 0.25 * outWidth;
            var outOffset = 0.5 * outWidth;
            //修改尺寸  okk但offset还要改
            function set(outWidth, inWidth) {
                inWidth = inWidth || 0.5 * outWidth;
                $(" .container .wrap .cube div").width(outWidth);
                $(" .container .wrap .cube span").width(inWidth);
            }
        })
    </script>
</body>
</html>

css代码

代码语言:javascript
复制
body {
    background-color: rgb(22, 21, 21);
}

/* 全模块定位和总布局 用定位top/left,没有margin但不脱标调位置 */

.container {
    position: relative;
    top: 200px;
    left: 200px;
}

/* 主要用来装功能块在容器内保证定位 相当于该功能块的padding*/

.container .wrap {
    width: 100px;
    height: 100px;
    top: 150px;
    left: 150px;
    margin: 0;
}

/* 功能块 */

.container .wrap .cube {
    width: 100px;
    height: 100px;
    transform-style: preserve-3d;
    transform: rotateX(-30deg) rotateY(-80deg);
    animation: ziZhuan linear 20s infinite;
    animation-direction: alternate-reverse;
    transition: all 0.5s;
}

@keyframes ziZhuan {
    0% {
        transform: rotateX(0deg) rotateY(0deg);
    }
    100% {
        transform: rotateX(360deg) rotateY(360deg);
    }
}

.container .wrap .cube div {
    position: absolute;
    top: 0;
    left: 0;
    width: 200px;
    height: 200px;
    background-color: rgb(0, 183, 255);
    z-index: -1;
    transition: all 0.5s;
    opacity: 0.45;
    outline: rgb(255, 255, 255) solid thick;
        box-shadow: rgba(255, 255, 255, 0.15) 0 0 50px 50px;
}

.container .wrap .cube div img {
    width: 100%;
    height: 100%;
}

.container .wrap .cube span {
    position: absolute;
    top: 50px;
    left: 50px;
    display: block;
    width: 100px;
    height: 100px;
    outline: rgba(21, 40, 211, 0.664) solid thin;
    background-color: rgba(11, 96, 224, 0.295);
}

.container .wrap .cube span img {
    width: 100%;
    height: 100%;
}

.container .wrap .cube .out-front {
    transform: rotateY(0deg) translateZ(100px);
}

.container .wrap .cube .out-back {
    transform: translateZ(-100px);
}


/* //y正方向逆时针 */

.container .wrap .cube .out-left {
    transform: rotateY(-90deg) translateZ(100px);
}

.container .wrap .cube .out-right {
    transform: rotateY(90deg) translateZ(100px);
}


/*  x->正-上*/

.container .wrap .cube .out-top {
    transform: rotateX(90deg) translateZ(100px);
}

.container .wrap .cube .out-bottom {
    background-color: rgba(36, 238, 80, 0.253);
    transform: rotateX(-90deg) translateZ(100px);
}

.container .wrap .cube .in-left {
    transform: rotateY(-90deg) translateZ(50px);
}

.container .wrap .cube .in-right {
    transform: rotateY(90deg) translateZ(50px);
}

.container .wrap .cube .in-back {
    transform: translateZ(-50px);
}

.container .wrap .cube .in-front {
    transform: translateZ(50px);
}

.container .wrap .cube .in-top {
    transform: rotateX(90deg) translateZ(50px);
}

.container .wrap .cube .in-bottom {
    transform: rotateX(-90deg) translateZ(50px);
}

.container .wrap .cube:hover .out-front {
    transform: rotateY(0deg) translateZ(200px);
}

.container .wrap .cube:hover .out-back {
    transform: rotateY(0deg) translateZ(-200px);
}

.container .wrap .cube:hover .out-top {
    transform: rotateX(90deg) translateZ(200px);
}

.container .wrap .cube:hover .out-bottom {
    transform: rotateX(-90deg) translateZ(200px);
}

.container .wrap .cube:hover .out-right {
    transform: rotateY(90deg) translateZ(200px);
}

.container .wrap .cube:hover .out-left {
    transform: rotateY(-90deg) translateZ(200px);
}
本文参与?腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客?前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与?腾讯云自媒体同步曝光计划? ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 效果图
  • HTML代码
  • css代码
相关产品与服务
容器服务
腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
http://www.vxiaotou.com