DEV Community

Cover image for CSS Battle: #10 - Cloaked Spirits
Jatin Sharma
Jatin Sharma

Posted on

CSS Battle: #10 - Cloaked Spirits

In this article, I will solve a Cloaked Spirits 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:
Cloaked Spirits

Solution

So now look at the Solution and how we are going to achieve this.


Video's Code is a little bit different because in the following CSS code I've used aspect-ratio just to reduce character and to match the width and height which is not mentioned in the video. (Video code also works fine)

HTML

<p b>
<p c>
Enter fullscreen mode Exit fullscreen mode

CSS

Now let's style the containers.

* {
  margin: 0;
  background: #62306d;
}
body {
  display: grid;
  place-items: center;
}
p {
  position: fixed;
  aspect-ratio: 1;
}
[b] {
  width: 100;
  background: #f7ec7d;
  box-shadow: -100px 100px #f7ec7d, 
              100px 100px #f7ec7d, 
              0 100px #f7ec7d;
}
[c] {
  width: 60;
  background: #aa445f;
  border-radius: 1in;
  bottom: 170;
  box-shadow: 0 0 0 20px #e38f66, 
              100px 100px #e38f66,
              100px 100px 0 20px #aa445f, 
              -100px 100px #e38f66,
              -100px 100px 0 20px #aa445f;
}
Enter fullscreen mode Exit fullscreen mode

Note: In CSS Battle you can use 100 instead of 100px. You don't need to define px in CSS. However, if you are using rem or %, you need to pass them separately. That's why in the above CSS code there are no units mostly. For more info visit here

Minify the code or CSS by using any CSS Minifier. It helps you to reduce the characters in the code which will increase the score.

Minified Version:

<p b><p c><style>*{margin:0;background:#62306D}body{display:grid;place-items:center}p{position:fixed}[b]{height:100;width:100;background:#F7EC7D;bottom:0;left:50;box-shadow:100px -100px #F7EC7D,100px 0 #F7EC7D,200px 0 #F7EC7D}[c]{width:60;height:60;background:#AA445F;border-radius:1in;bottom:170;box-shadow:0 0 0 20px #E38F66,100px 100px #E38F66,100px 100px 0 20px #AA445F,-100px 100px #E38F66,-100px 100px 0 20px #AA445F}
Enter fullscreen mode Exit fullscreen mode

Wrapping up

If you like this then don't forget to ❤️ it. And I'll see you in the next article. See you soon.

Top comments (2)

Collapse
 
gass profile image
Gass

That's impressive. Your solution is super short. This was mine

<section class='container'>
  <div></div>
  <div class='bg-one'>
    <div class='circle type-two'></div>
  </div>
  <div></div>
  <div class='bg-one'>
    <div class='circle type-one'></div>
  </div>
  <div class='bg-two'></div>
  <div class='bg-one'>
    <div class='circle type-one'></div>
  </div>
</section>
<section class='yellow-base'></section>
Enter fullscreen mode Exit fullscreen mode
    body{
      margin:0;
      position:absolute;
      right: calc(50% - 150px);
      bottom:0;
      background:#62306D;
    }
    .container{
      width:300px;
      height:200px;
      display:grid;
      grid-template-columns: repeat(3,1fr);
      grid-template-rows: repeat(2,1fr);
    }
    .circle{
      margin:0px 20px 20px 20px;
      height:60px;
      width:60px;
      border-radius:100%;
    }
    .type-one{
      background:#E38F66;
      box-shadow:0 0 0 20px #AA445F;
    }
    .type-two{
      background:#AA445F;
      box-shadow:0 0 0 20px #E38F66;
    }
    .bg-one{
      margin-top:20px;
       border-radius: 100% 100% 0 0;
      background:#F7EC7D;
    }
    .bg-two{
      background:#F7EC7D;
    }
    .yellow-base{
      width:300px;
      height:50px;
      background:#F7EC7D;
    }
Enter fullscreen mode Exit fullscreen mode
Collapse
 
j471n profile image
Jatin Sharma

It's a little longer, but never mind until it works.