Using SVG:
You can easily create this using SVG. There is nothing complicated, and all you need is three linear elements and one path element.
svg { height: 100px; width: 50px; } line, path { stroke: #e74c3c; stroke-width: 2; } path { fill: none; stroke-linejoin: bevel; }
<svg viewBox='0 0 100 100' preserveAspectRatio='none'> <g id='graphic'> <line x1='5' y1='5' x2='95' y2='5' /> <line x1='5' y1='10' x2='95' y2='10' /> <line x1='5' y1='15' x2='95' y2='15' /> <path d='M5,20 L95,20 L50,45z' /> </g> </svg>
Using CSS with one element:
You can achieve the same form using one element also with CSS. Below is an example snippet for the same. The following is an explanation of how the form is achieved.
- The main anchor tag that has the height and width of the container.
- The
:before pseudo-element, which is positioned absolutely in relation to the container and has a height of 20 pixels. The background of this element is a linear gradient that has the desired color for 2px and is transparent for the rest. The default gradients are repeated to fill your container, and so this single background image creates three lines. - The
:after element :after again positioned absolutely in relation to the container. This pseudo-element is then rotated so that its left and lower borders create the angular parts of the triangle. Another linear gradient background creates the top line of the triangle. - I calculated the height and width of the
:after pseudotherapy using the Pythagorean theorem. If the container is not a square, you need to manually calculate the values.
a { position: relative; display: inline-block; height: 50px; width: 50px; } a:before { position: absolute; content: ''; top: 3px; left: 0px; height: 20px; width: 100%; background: linear-gradient(to bottom, #e74c3c 2px, transparent 2px); background-size: 100% 5px; } a:after { position: absolute; content: ''; top: 50%; left: 50%; height: calc(50px / 1.414); width: calc(50px / 1.414); border-bottom: 2px solid #e74c3c; border-left: 2px solid #e74c3c; transform: translateX(-50%) translateY(-50%) rotate(-45deg); background: linear-gradient(to top right, transparent 46%, #e74c3c 46%, #e74c3c 50%, transparent 50%); }
<a href='#'></a>
Harry source share