css实现立体阴影盒子——transform

效果图如下:

 

首先设置body主要结构体,这里是三个div盒子,分别对应三个立体面

<div class="stage">
        <div class="container">
            <div id="left"><p>LEFT</p></div>
            <div id="top"><p>TOP</p></div>
            <div id="right"><p>RIGHT</p></div>
        </div>
    </div>

对立体面文字的样式设置:

P{
            color: rgb(252, 247, 247);
            font-weight: bold;
            text-align: center;
            padding-top: 40px;
           
        }

然后对左侧的样式设计:transform里面是两个属性(倾斜和位移)的合并

#left{
            background-color: rgb(199, 199, 206);
            width: 100px;
            height: 100px;
            transform: skew(0,20deg) translate(50%, 100%) ;

        }

右侧的样式基本差不多,但是背景用渐变(从上到下)来突出阴影的效果:

#right{
            background:linear-gradient(to bottom,rgb(199, 199, 206),rgb(140, 143, 140));
            width: 100px;
            height: 100px;
            
           
            transform:  skew(0,-20deg) translate(150%,-59%);

        }

上面的样式:rotate取负是逆时针旋转45°,缩放0.97,倾斜x轴是25°,y轴是25°,最后移动对象到指定位置。

#top{
            background-color: rgb(187, 184, 184);
            width: 100px;
            height: 100px;
            
            transform: rotate(-45deg) scale(0.97) skew(25deg,25deg) translate(140%,-40%);
        }

最后就完成啦

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值