3D立体书架切换效果(一)


最终效果图

第一步:用css制作书本立体效果

html代码如下

四个面 54037060

<div class="cuboid">
        <div class="right"></div>
        <div class="left"></div>
        <div class="back"></div>
        <div class="front"></div>
</div>

scss代码(注意是scss不是css)

* {
  padding: 0;
  margin: 0;
}
/*
*scss代码(注意是scss不是css)
*/
// 长方体模型
//配置文件
$width: 540px;
$height: 370px;
$depth: 60px;


.cuboid {
  width: $depth;
  height: $height;
  transform-style: preserve-3d;
  /* 使得所有子元素在3D空间中呈现 */
  transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  
  div {
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;		//侧面的高度相同
  }
  // 背面
  .back{
    width: $depth;
    transform:  translateZ(-$width/2) rotateY(180deg);
      background-color: aqua;
      }
  //前面
  .front{
    width: $depth;
    transform:  translateZ($width/2);
    background-color: red;
  }
  // 左面
  .left{
    width:$width;
    transform:  translateX(-$width/2) rotateY(-90deg);
      background-color: rgb(3, 235, 235);
      }
  // 右面
  .right{
    width:$width;
    transform:  translateX(-$width/2+$depth) rotateY(90deg);
      background-color: rgb(235, 235, 3);
      }
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值