我需要帮助在CSS / jQuery / SVG / Canvas中创建类似上图的内容
每个三角形都包含一个需要裁剪的图像以适应三角形,一切都需要响应。
我通过CSS边框设法做到这一点,但令我惊讶的是我无法添加图像。
非常感谢任何提示或信息。
通过CSS获得的示例:
<div class="middle_section" style="height: 900px;">
<div class="one_forth triangleMask for_1"></div>
<div class="one_forth triangleMask for_2"></div>
<div class="one_forth triangleMask for_3"></div>
<div class="one_forth triangleMask for_4"></div>
</div>
.middle_section .for_3,
.middle_section .for_1{
width: 100%;
height: 50%;
overflow: hidden;
}
.middle_section .for_2,
.middle_section .for_4{
width: 50%;
height: 100%;
overflow: hidden;
}
.middle_section .for_1:after {
width: 0;
height: 0;
border-style: solid;
border-width: 440px 808px 0px 808px;
border-color: #ff0000 transparent transparent transparent;
content: '';
position: absolute;
top:0;
left:10px;
}
.middle_section .for_2:after {
width: 0;
height: 0;
border-top: 440px solid transparent;
border-bottom: 440px solid transparent;
border-left: 808px solid lime;
content: '';
position: absolute;
top:10px;
}
.middle_section .for_3:after {
width: 0;
height: 0;
border-left: 808px solid transparent;
border-right: 808px solid transparent;
border-bottom: 440px solid #4679BD;
content: '';
position: absolute;
bottom:0;
left:10px;
}
.middle_section .for_4:after {
width: 0;
height: 0;
border-top: 440px solid transparent;
border-bottom: 440px solid transparent;
border-right: 808px solid pink;
content: '';
position: absolute;
top:10px;
right:0;
}
答案 0 :(得分:0)
我用CSS变换旋转做了一个例子:
.wrapper {
width:284px;
height:281px;
overflow: hidden;
position: relative;
}
.top {
transform: rotate(45deg);
position: absolute;
top:-100px;
left: 40px;
}
.bottom {
transform: rotate(45deg);
position: absolute;
bottom: -105px;
left: 40px;
}
.left {
transform: rotate(45deg);
position: absolute;
left: -102px;
top: 41px;
}
.right {
transform: rotate(45deg);
position: absolute;
right: -98px;
top: 41px;
}
&#13;
<div class="wrapper">
<div class="top">
<img src="http://lorempixel.com/200/200/sports/1"/>
</div>
<div class="bottom">
<img src="http://lorempixel.com/200/200/sports/2"/>
</div>
<div class="left">
<img src="http://lorempixel.com/200/200/sports/3"/>
</div>
<div class="right">
<img src="http://lorempixel.com/200/200/sports/5"/>
</div>
</div>
&#13;