<----------------------------------------------- clip-path
solution ------------------------------------------------->
You could use clip-path
to do this:
.rect {
position: absolute;
width: 165px;
height: 100px;
background-color: black;
-webkit-clip-path: polygon(0 0, 0 100%, 40% 100%, 50% 75%, 60% 100%, 100% 100%, 100% 0%);
}
body {
background-color: lightblue;
}
Note: Firefox does not support this property.
Works fine on Chrome.
Check out the browser support for clip-path
----------> HERE.
<------------------------- <svg>
solution - will support all browsers [except IE8] ------------------------->
Since, Firefox still supports clip-path: url()
, you can create an inline svg
element with a polygon
element inside clipPath
that defines the points
. Give the clipPath
element an id
(#mask
) and use it in CSS instead of polygon(0 0, 0 100%, 40% 100%, 50% 75%, 60% 100%, 100% 100%, 100% 0%);
.
HTML:
<div class="rect"></div>
<svg>
<defs>
<clipPath id="mask">
<polygon points="0,0 0,100 66,100 82.5,75 99,100 165,100 165,0 " />
</clipPath>
</defs>
</svg>
CSS:
.rect {
position: absolute;
width: 165px;
height: 100px;
background-color: black;
-webkit-clip-path: url(#mask);
clip-path: url(#mask);
}
body {
background-color: lightblue;
}
<---------------------------------------- <svg>
solution without any CSS ---------------------------------------->
HTML:
<svg>
<polygon points="0,0 0,100 66,100 82.5,75 99,100 165,100 165,0" style="fill:black" />
</svg>
Check out browsers that supports svg
----------> HERE