You can use the :before and :after pseudo-elements:
body{ background:black; } div{ border-top:1px solid green; position:relative; margin-top: 100px; } div:before{ content: ''; position:absolute; left: calc(90% - 20px); top: -9px; width: 0; height: 0; border-style: solid; border-width: 0 10px 10px 10px; border-color: transparent transparent black transparent; z-index: 10; } div:after{ content: ''; position:absolute; right:10%; top: -10px; width: 0; height: 0; border-style: solid; border-width: 0 10px 10px 10px; border-color: transparent transparent green transparent; }
<div></div>
Basically, there are two triangles, one of which has a background color with a large z-index , and the other in the border color.
Jsfiddle
Update
As @misterManSam mentioned, you can achieve this without using the z-index fiddle
source share