CSS Logos: Hashnode logo

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
Search for a command to run...

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
Using the mask property is an interesting approach, never have I used it before.
Thanks for sharing!
Nice Chris Bongers
I'm glad you enjoyed it Adan 💖
Thanks! Glad you like it 💖
Most of you know me for my consistency, a golden arrow in my blog series. I've written 1000 articles in 1008 days! Almost an article a day, and my honeymoon was the only holiday I ever took. I'm super proud of this achievement; it has been a fantasti...

It's not the first time I'll be talking about community. I think it's an essential aspect of any successful tool. This shows in my previous explorations of Astro, Medusa, and now Vendure as well. All these products thrive in a super open, welcoming, ...

The cool part about Vendure is how easy it is to set up and how abstract each layer is. Basically, we get the following elements: External database Server Worker Admin UI Frontend While this is amazing, it also brings a bit of complexity when it co...

The previous article looked at customizing Vendure on a data and process level. In this article, we'll look at customizing emails, as they are often a big part of a webshop system. We'll be looking at two different layers of customization for customi...

Even though Vendure is a pretty significant project out of the box, in some cases, we might want to go in and modify some elements to work to our specific use case. In this article, I'll take a high-level look at some elements we can customize within...

I wanted to start this CSS challenge a while ago by recreating some fantastic logos in CSS only.
I'll be starting with Hashnode, as I re-created this recently for the CSS Hashnode challenge.
See my result of the challenge here
While looking at the logo, we can quickly see a rounded square with a hole in it.

This sounds easy enough. However, one thing will make it a bit more complicated.
This is the fact that making the whole see-through can be pretty tricky.
So let's split this up into two sections, one in which we'll make it with a solid color and one that is see-through.
We first have to start by creating the rounded square that is rotated a bit.
For the HTML, we'll be using one div with the class hashnode.
.hashnode {
width: 5em;
aspect-ratio: 1;
border-radius: 1.25em;
background: #2962ff;
transform: rotate(45deg);
}
Using the aspect ratio, we make sure the logo is square. We also rotate it by 45 degrees, so it has the same position. At this point, you should have a block looking like this.

Now we can leverage the before element to add the white dot on top of this.
&:before {
content: '';
border-radius: 50%;
background: white;
height: 2em;
aspect-ratio: 1;
}
And with this, we get a simple round shape. To center the round element, we can add the following two elements to our main wrapper div.
.hashnode {
display: grid;
place-items: center;
}
And there you go, you should now have the following result:
The main issue with the above solution is that we can't have anything in the background as it would not show through.
So let's try and change that.
The main setup will be the exact same as the above solution:
.hashnode {
width: 5em;
aspect-ratio: 1;
border-radius: 1.25em;
background: #2962ff;
transform: rotate(45deg);
}
Then we can leverage a mask to mask out the middle section.
-webkit-mask: radial-gradient(#0000 28%, #000 28%);
mask: radial-gradient(#0000 28%, #000 28%);
This will mask out the center element, so we can add a background and see what happens.
As you can see in the CodePen above, the background shows through the logo, excellent! The mask option is a powerful tool to mask out parts of your elements.
Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter