我一直在尝试用纯 CSS 制作背景(在边框属性的帮助下使用 CSS 三角形),到目前为止我很成功。但是有一个溢出问题正在摧毁整个事情。
如上图所示;我想要第三个立方体正好在第二个立方体的右侧(半隐藏)。
CSS:
.cube {
float: left;
height:239px;
width:200px;
}
.cube .top {
}
.cube .top .high{
width: 0;
height: 0;
border-bottom: 60px solid #46B535;
border-left: 100px solid transparent;
border-right: 100px solid transparent;
}
.cube .top .low {
width: 0;
height: 0;
border-top: 60px solid #46B535;
border-left: 100px solid transparent;
border-right: 100px solid transparent;
}
.cube .left {
float: left;
position: relative;
top: -60.7px;
}
.cube .left .high {
width: 0;
height: 0;
border-bottom: 60px solid #59BE32;
border-right: 100px solid transparent;
}
.cube .left .mid {
height: 60px;
width: 100px;
background: #59BE32;
}
.cube .left .low {
width: 0;
height: 0;
border-top: 60px solid #59BE32;
border-left: 100px solid transparent;
}
.cube .right {
float: left;
position: relative;
top: -60.7px;
}
.cube .right .light .up {
width: 0;
height: 0;
border-bottom: 60px solid #27B138;
border-left: 100px solid transparent;
}
.cube .right .light .down {
width: 0;
height: 0;
border-top: 60px solid #27B138;
border-left: 100px solid transparent;
}
.cube .right .dark {
position: relative;
top: -61px;
}
.cube .right .dark .up {
width: 0;
height: 0;
border-bottom: 60px solid #00AA3A;
border-right: 100px solid transparent;
}
.cube .right .dark .down {
width: 0;
height: 0;
border-top: 60px solid #00AA3A;
border-right: 100px solid transparent;
}
.clear {
clear: both;
}
.even {
clear: both;
overflow:hidden;
height:36%;
}
HTML:
<section class="even">
<section class="cube">
<div class="top">
<div class="high"></div>
<div class="low"></div>
</div>
<div class="left">
<div class="high"></div>
<div class="mid"></div>
<div class="low"></div>
</div>
<div class="right">
<div class="light">
<div class="up"></div>
<div class="down"></div>
</div>
<div class="dark">
<div class="up"></div>
<div class="down"></div>
</div>
</div>
</section>
<section class="cube">
<div class="top">
<div class="high"></div>
<div class="low"></div>
</div>
<div class="left">
<div class="high"></div>
<div class="mid"></div>
<div class="low"></div>
</div>
<div class="right">
<div class="light">
<div class="up"></div>
<div class="down"></div>
</div>
<div class="dark">
<div class="up"></div>
<div class="down"></div>
</div>
</div>
</section>
<section class="cube">
<div class="top">
<div class="high"></div>
<div class="low"></div>
</div>
<div class="left">
<div class="high"></div>
<div class="mid"></div>
<div class="low"></div>
</div>
<div class="right">
<div class="light">
<div class="up"></div>
<div class="down"></div>
</div>
<div class="dark">
<div class="up"></div>
<div class="down"></div>
</div>
</div>
</section>
</section>
JSF中: