CSS3干货17:纯CSS的几种图片投影制作

 纯CSS3 制作图片投影,各种投影,不许要图片制作了。

HTML代码:

<div class="box shadow1"><img src="images/mm.jpg" alt=""></div>
<div class="box shadow2"><img src="images/mm.jpg" alt=""></div>
<div class="box shadow3"><img src="images/mm.jpg" alt=""></div>
<div class="box shadow4"><img src="images/mm.jpg" alt=""></div>
<div class="box shadow5"><img src="images/mm.jpg" alt=""></div>
<div class="box shadow6"><img src="images/mm.jpg" alt=""></div>
<div class="box shadow7"><img src="images/mm.jpg" alt=""></div>
<div class="box shadow8"><img src="images/mm.jpg" alt=""></div>
<div class="box shadow9"><img src="images/mm.jpg" alt=""></div>

CSS3 代码:

        .box{
            width: 308px;
            height: 287px;
            margin: 50px;
            background: #ccc;
            float: left;
            border:1px #999 solid;
        }
        .box img{
            display: block;
            width: 300px;
            height: 279px;
            border:4px #fff solid;
        }
        .shadow1{
            box-shadow: 25px 25px 5px rgba(0,0,0,0.4);
        }

        .shadow2{
            box-shadow: 0  0  10px rgba(0,0,0,0.8);
        }

        .shadow3 {
            box-shadow: 0  0  20px rgba(0,0,0,0.8) ;
        }

        .shadow4{
            position: relative;
        }
        .shadow4:before{
            content: "";
            width: 100%;
            height: 100%;
            background: #000;
            display: block;
            position: absolute;
            z-index: -1;
            top:5px;
            left:5px;
        }

        .shadow5{
            position: relative;
        }
        .shadow5:before{
            content: "";
            width: 80%;
            height: 40px;
            background: rgba(0,0,0,0.5);
            display: block;
            position: absolute;
            z-index: -1;
            top:260px;
            left:10%;
            filter:blur(5px);
            border-radius: 50%;
        }

        .shadow6{
            position: relative;
        }
        .shadow6:before{
            content: "";
            width: 80%;
            height: 40%;
            background: linear-gradient(left , rgb(0, 0, 0) 47% , rgba(0, 0, 0, 0) 100%);
            background: -o-linear-gradient(left , rgb(0, 0, 0) 47% , rgba(0, 0, 0, 0) 100%);
            background: -ms-linear-gradient(left , rgb(0, 0, 0) 47% , rgba(0, 0, 0, 0) 100%);
            background: -moz-linear-gradient(left , rgb(0, 0, 0) 47% , rgba(0, 0, 0, 0) 100%);
            background: -webkit-linear-gradient(left , rgb(0, 0, 0) 47% , rgba(0, 0, 0, 0) 100%);
            display: block;
            top:62%;
            left:10%;
            position: absolute;
            z-index: -1;
            transform: rotateZ(5deg);
            opacity: 0.5;
        }

        .shadow7{
            position: relative;
        }
        .shadow7:before{
            content: "";
            width: 100%;
            height: 40%;
            background: linear-gradient(top , rgb(0, 0, 0) 0% , rgba(0, 0, 0, 0) 100%);
            background: -o-linear-gradient(top , rgb(0, 0, 0) 0% , rgba(0, 0, 0, 0) 100%);
            background: -ms-linear-gradient(top , rgb(0, 0, 0) 0% , rgba(0, 0, 0, 0) 100%);
            background: -moz-linear-gradient(top , rgb(0, 0, 0) 0% , rgba(0, 0, 0, 0) 100%);
            background: -webkit-linear-gradient(top , rgb(0, 0, 0) 0% , rgba(0, 0, 0, 0) 100%);
            display: block;
            top:100%;
            left:0;
            position: absolute;
            z-index: -1;
            opacity: 0.2;
        }

        .shadow8{
            position: relative;
        }
        .shadow8:before{
            content: "";
            width: 100%;
            height: 10%;
            background: rgba(0,0,0,0.4);
            display: block;
            top:110%;
            left:0;
            position: absolute;
            z-index: -1;
            border-radius: 50%;
            filter: blur(5px);
        }

        .shadow9{
            position: relative;
        }
        .shadow9:before{
            content: "";
            width: 50%;
            height: 90%;
            background: rgba(0,0,0,0.2);
            display: block;
            top:10%;
            left:0;
            position: absolute;
            z-index: -1;
            filter: blur(2px);
            transform-origin: right top;
            transform: rotateZ(-5deg);
        }

        .shadow9:after{
            content: "";
            width: 50%;
            height: 90%;
            background: rgba(0,0,0,0.2);
            display: block;
            top:10%;
            right:0;
            position: absolute;
            z-index: -1;
            filter: blur(2px);
            transform-origin: left top;
            transform: rotateZ(5deg);
        }

喜欢的小伙伴们,赶紧试试吧~

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值