【发布时间】:2017-03-25 17:28:25
【问题描述】:
我需要帮助在 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;
}
【问题讨论】:
-
你能分享你的代码吗?
-
你能提供你的试用代码
-
以上代码更新
-
感谢您的代码,但您的问题是什么?你说你想做某事,发布代码,但代码是做什么的?为什么它不起作用?这段代码的问题在哪里?
-
嗨,阿德里安,感谢您的帮助,问题是我无法在三角形内添加图像
标签: javascript jquery css canvas svg