使用纯 CSS(3) 你可以做到。我们需要transform:skew()
. 每个盒子都有自己的div
. CSS 每个div
. :before
需要伪元素来“修复”两个底部元素的不需要的顶部倾斜。
HTML
<div class="origami">
<div class="origami-box origami-box1"></div>
<div class="origami-box origami-box2"></div>
<div class="origami-box origami-box3"></div>
<div class="origami-box origami-box4"></div>
<div class="origami-content">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>
</div>
CSS
.origami {
margin-top:100px;
margin-left:100px;
width:160px;
position:relative;
}
.origami-box {
height:80px;
width:80px;
float:left;
}
.origami-box1 {
background:red;
-webkit-transform:skew(0deg,-4deg);
-moz-transform:skew(0deg,-4deg);
transform:skew(0deg,-4deg);
}
.origami-box2 {
background:blue;
-webkit-transform:skew(0deg,4deg);
-moz-transform:skew(0deg,4deg);
transform:skew(0deg,4deg);
}
.origami-box3 {
background:green;
-webkit-transform:skew(0deg,4deg);
-moz-transform:skew(0deg,4deg);
transform:skew(0deg,4deg);
}
.origami-box.origami-box3:before {
content: "";
display: block;
width: 80px;
height: 80px;
position: relative;
top: -3px;
background: green;
-webkit-transform: skew(0deg,-4deg);
-moz-transform: skew(0deg,-4deg);
transform: skew(0deg,-4deg);
}
.origami-box4 {
background:yellow;
-webkit-transform:skew(0deg,-4deg);
-moz-transform:skew(0deg,-4deg);
transform:skew(0deg,-4deg);
}
.origami-box.origami-box4:before {
content: "";
display: block;
width: 80px;
height: 80px;
position: relative;
top: -3px;
background: yellow;
-webkit-transform: skew(0deg,4deg);
-moz-transform: skew(0deg,4deg);
transform: skew(0deg,4deg);
}
.origami-content {
position:absolute;
top:10px;
padding:10px;
}
演示:http: //jsfiddle.net/Qwd4R/1