How to make this heart icon

I have made heart icon using 2 circles and one div angled. But i cant make it just show border of heart shape and make inside of heart transparent. I want heart like this where it just shows outline of heart and inside it must be transparent. When click on it , it should turn red. Any kind of help i will be very thankful❤️.
No description
14 Replies
vince
vince8mo ago
Use an svg
ChooKing
ChooKing8mo ago
If you are able to make one solid heart, then you can make the outline by stack one smaller heart on top of a larger one.
C_7
C_78mo ago
'Font icons' || 'canvas'
Rägnar O'ock
Rägnar O'ock8mo ago
Icon fonts are not great as you for the user to download a (usually rather heavy) font for only a few icons. The trade off can be ok if you usea lot of icons, but most likely you won't. Canvas should not be used for that. Both are bad for accessibility. So as Vince said, svg is the way. You could use a png or a jpeg too, but the last two would be heavier that an svg and would not scale up as well if you needed them to.
MarkBoots
MarkBoots8mo ago
svg's indeed are the better solution But as a little fun exercise for my self, I did it with a single div. with borders and clippath https://codepen.io/MarkBoots/pen/vYvPOpZ
Jus Sus || 💀
Jus Sus || 💀8mo ago
@MarkBoots Achieved this using svg. but am actually impressed by this solution you provided. Thanks!
Chris Bolson
Chris Bolson8mo ago
I didn't want to be left out so have also created an alternative CSS only method in a slightly different way https://codepen.io/cbolson/pen/wvROMzG Whilst simple enough, it is not really practical as it has too many magic numbers.
MarkBoots
MarkBoots8mo ago
yea about the same idea. i did needed the clip to get rid of the overlapping border incase of no bg
ἔρως
ἔρως8mo ago
icons.getbootstrap.com has a full and an empty heart that you can use freely without having to add any license information (if you dont use a "substantial" set of the icons) dont re-invent the wheel with css and stuff, if there is a much more robust solution it has a filled and an empty heart if you need to fill it on hover or something, that isnt hard
Zoë
Zoë8mo ago
Also because there is a gradient behind make the smaller heart black and then use mix-blend-mode: lighten on the hearts so that the lighter background shows through
Chris Bolson
Chris Bolson8mo ago
I missed the bit about being transparent 🤦‍♂️ ... I have done another one with a slightly different approach. This version also fixes the need for magic-numbers https://codepen.io/cbolson/pen/wvROMdz
MarkBoots
MarkBoots8mo ago
nice, was thinking about that way too.
ἔρως
ἔρως8mo ago
that has some gaps:
No description
ἔρως
ἔρως8mo ago
if you really want to use css, why not a clip-path? it is percent based, so, should look good no matter the size