Jatin Sharma
Posted on July 23, 2022
In this article, I will solve a Tesseract CSS Challenge on CSS Battle. Let's look at the problem first.
Problem
We need to create the following container by using CSS Properties only:
Solution
So now look at the Solution and how we are going to achieve this.
HTML
<div class="rect"></div>
<div class="square"></div>
<div class="circle"></div>
CSS
Now let's style the containers.
body {
margin: 0;
background: #222730;
display: grid;
place-items: center;
}
.rect {
width: 100%;
height: 150px;
background: #4caab3;
}
.square {
position: absolute;
width: 150px;
height: 150px;
background: #4caab3;
transform: rotate(45deg);
box-shadow: 0 0 0 50px #222730;
}
.circle {
position: absolute;
width: 50px;
height: 50px;
background: #393e46;
border-radius: 50px;
}
Note: In CSS Battle you can use
100
instead of100px
. You don't need to definepx
in CSS. However, if you are usingrem
or%
, you need to pass them separately. That's why in the above CSS code there are no units mostly. For more info visit hereMinify the code or CSS by using any CSS Minifier. It helps you to reduce the characters in the code which will increase the score.
Wrapping up
There are many ways to solve this. You can share your approach in the comments. If you like this then don't forget to ❤️ it. And I'll see you in the next article. See you soon.
Posted on July 23, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.