如何通过3D变换实现折纸效果

时间:2016-03-22 12:43:41

标签: jquery html css

我正在尝试对div进行折纸效果而我真的不知道如何。我将上传2张纸张图片,看看我的意思This is my current div

and this is what i want to change.

我如何变换像这样的div?我希望它具有相同的折纸效果

1 个答案:

答案 0 :(得分:4)

使用高度,宽度和边框进行游戏,将尺寸更改为您想要的尺寸。

 body {
   padding: 150px 150px;
 }

/* Horizontal part of the ribbon */
 .fribbon {
    padding: 0 25px;
    height: 60px; 
    background: #e7e7e7;     
    position: relative;
    float: left;
    clear: left;
    }

/* Vertical part of the ribbon */
.fribbon:after {
    content: "";    
    display: block;
    width: 40px;
    height: 0px;
    position: absolute;
    right: 0;
    bottom: 0px;
    z-index: 20;
    border-bottom: 60px solid #e7e7e7;
    border-right: 60px solid transparent;
  
    /* Brwoser-specific rules */
    -webkit-transform: rotate(90deg);
    -webkit-transform-origin: right bottom;
    -moz-transform: rotate(90deg);
    -moz-transform-origin: right bottom;
    -o-transform: rotate(90deg);
    -o-transform-origin: right bottom;
    -ms-transform: rotate(90deg);
    -ms-transform-origin: right bottom;
    transform: rotate(90deg);
    transform-origin: right bottom;
    }

/* Shadow part of the ribbon */    
    .fribbon:before {
    content: "";    
    display: block;
    width: 20px;
    height: 0px;
    position: absolute;
    right: 0;
    bottom: 0px;
    z-index: 10;
    border-bottom: 60px solid rgba(0, 0, 0, 0.3);
    border-right: 60px solid transparent;
     
    /* Brwoser-specific rules */
    -webkit-transform: rotate(80deg);
    -webkit-transform-origin: right bottom;
    -moz-transform: rotate(80deg);
    -moz-transform-origin: right bottom;
    -o-transform: rotate(80deg);
    -o-transform-origin: right bottom;
    -ms-transform: rotate(80deg);
    -ms-transform-origin: right bottom;
    transform: rotate(80deg);
    transform-origin: right bottom;
    }
<div class="fribbon"></div>