CSS3中3D环境实现立体的魔方效果代码分享

发布时间:2021-08-09 11:09:23 作者:chen
来源:亿速云 阅读:136

这篇文章主要介绍“CSS3中3D环境实现立体的魔方效果代码分享”,在日常操作中,相信很多人在CSS3中3D环境实现立体的魔方效果代码分享问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”CSS3中3D环境实现立体的魔方效果代码分享”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

<!DOCTYPE html>

  <html lang="en">

  <head>

     <meta charset="UTF-8">

      <title>魔方</title>

      <style type="text/css">

          section{width: 100px;height:100px;border:5px solid red; margin:50px auto;padding:100px;perspective: 800px;}

          .box {width:100px;height:100px;position:relative;

              transform-style:preserve-3d;

             transition:4S;

             transform-origin:center center -50px;

         }

         .box div{width: 100px;height:100px;position:absolute;color:white;font-size:50px;text-align: center;line-height:100px;}

         .box div:nth-of-type(1){

             background: #FF6600;;

             transform:translateX(-100px) rotateY(-90deg);

             transform-origin:right;

         }

         .box div:nth-of-type(2){

             background:red ;

             transform:translateY(-100px) rotateX(90deg);

             transform-origin:bottom ;

                  }

         .box div:nth-of-type(3){

             background:darkviolet;

             transform:translateX(100px) rotateY(90deg);

             transform-origin:left;

         }

         .box div:nth-of-type(4){

             background:yellow;

             transform: translateY(100px) rotateX(-90deg) ;

             transform-origin:top;

         }

         .box div:nth-of-type(5){

             background:green;

             transform:translateZ(-100px) rotateY(180deg);

         }

         .box div:nth-of-type(6){

             background:blue;

         }

         section:hover .box{

             transform: rotateX(270deg) rotateY(-270deg) rotateX(-270deg) rotateY(270deg) ;

         }

     </style>

 </head>

 <body>

    <section>

         <div class="box">

             <div>1</div>

             <div>2</div>

             <div>3</div>

             <div>4</div>

             <div>5</div>

             <div>6</div>

         </div>

     </section>

 </body>

  </html>

到此,关于“CSS3中3D环境实现立体的魔方效果代码分享”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

推荐阅读:
  1. 怎么使用css3实现魔方的动画效果
  2. H5如何实现旋转立体魔方

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

css3 css

上一篇:Spring Boot Hazelcast Caching怎么用

下一篇:基于Spring Boot不同环境如何使用不同的配置方法

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》