html创建一个横跨页面宽度的三角形

时间:2017-02-10 06:25:12

标签: html css

我想在html中创建一个跨越页面宽度的两个div之间的三角形(见下图)。

enter image description here

我不确定arrow_down div的css应该是什么

<div id="top_section" style="width:100%;">
 <div id="arrow_down">
 </div>
</div>
<div id="bottom_section" style="width:100%;">
</div>

1 个答案:

答案 0 :(得分:4)

使用伪元素:在

之后
#top_section:after {
    content:'';
    position: absolute;
    top: 100%;
    left: 0;
    width: 0;
    height: 0;
    border-top: solid 60px #ddd;
    border-left: solid 50vw transparent;
    border-right: solid 50vw transparent;
}

http://jsfiddle.net/gb6otzqr/