I am creating a small stylised triangular motif 'before' my h1 element, but I am not able to get the corners rounded correctly. The top right is fine but the other two has this clipping issue.
Here is the output along with a blown up image of the shape:
The code used is below:
h1:before {
content: "";
display: inline-block;
width: 0.7em;
height: 0.7em;
margin-right: 10px;
clip-path: polygon(100% 0%, 100% 100%, 0% 0%);
-webkit-clip-path: polygon(100% 0%, 100% 100%, 0% 0%);
background-color: #34495e;
border-radius: 0.12em;
}
<h1>Heading</h1>
I would like all corners to be smoothly rounded without any sharp corners. Perhaps there is a better way to do this. Any other tips to improve this are also welcome.
Here is an idea where you can rely on 2 pseudo element and some background coloration to approximate it. You simply need to find the correct value to have the perfect overlap between both pseudo elements.
h1 {
padding-left:1em;
position:relative;
}
h1:before {
content: "";
position:absolute;
left: 0;
top: calc(50% - 0.35em);
width: 0.7em;
height: 0.7em;
background: linear-gradient(to bottom left, #34495e 50%, transparent 50%);
border-radius: 0.1em;
}
h1:after {
content: "";
position: absolute;
left: 3.8px;
top: -0.1px;
width: 0.92em;
height: 0.8em;
margin-right: 10px;
background: linear-gradient(to top,#34495e 3.5px,transparent 5px);
border-radius: 0.1em;
transform: rotate(45deg);
z-index: -1;
}
<h1>Heading</h1>