DEV Community

Cover image for CSS Battle: #11 - Eye of Sauron
Jatin Sharma
Jatin Sharma

Posted on

CSS Battle: #11 - Eye of Sauron

In this article, I will solve a Eye of Sauron 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:
Eye of Sauron

Solution

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

HTML

<p c>
<p l>
<p r> 
Enter fullscreen mode Exit fullscreen mode
  • <p c> : For Center Circle
  • <p l> : For Left Semicircle
  • <p r> : For Right Semicircle

CSS

Now let's style the containers.

body {
  margin: 0;
  background: #191210;
}
p {
  position: fixed;
}
[c] {
  width: 50;
  height: 50;
  background: #84271c;
  border-radius: 1in;
  border: 25px solid #191210;
  box-shadow: 0 0 0 20px #eca03d;
  left: 150;
  top: 84;
}
[l],[r] {
  width: 60;
  height: 30;
  border: 20px solid #eca03d;
  border-radius: 0 0 1in 1in;
  border-top: none;
}
[l] {
  left: 50;
  top: 134;
}

[r] {
  right: 50;
  bottom: 134;
  transform: scaleY(-1);
}
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 c><p l><p r><style>body{margin:0;background:#191210}p{position:fixed}[c]{width:50;height:50;background:#84271C;border:25px solid #191210;border-radius:1in;box-shadow:0 0 0 20px #ECA03D;left:150;top:84}[l],[r]{width:60;height:30;border:20px solid #ECA03D;border-top:none;border-radius:0 0 1in 1in}[l]{left:50;top:134}[r]{right:50;bottom:134;transform:scaleY(-1)}
Enter fullscreen mode Exit fullscreen mode

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.

Top comments (2)

Collapse
 
gass profile image
Gass

Do you really code CSS as fast as in the video ? .. I liked your approach with the border-top: none .. I didn't think about that..

My code is longer, as usual :D .... I'm not really interested in coding short code. For me shorter code does not mean better code...

<div class='outer-circle'>
  <div class='inner-circle'></div>
</div>
<div class='special left'>
  <div></div>
  <div></div>
</div>
<div class='special right'>
  <div></div>
  <div></div>
</div>
Enter fullscreen mode Exit fullscreen mode
  body{background: #191210}
  *{aspect-ratio:1}
  .outer-circle{
    width:140px;
    position:absolute;
    z-index:1;
    top:calc(50% - 70px);
    left:calc(50% - 70px);
    background: #ECA03D;
    border-radius:100%;
    display:grid;
    place-items:center;
  }
  .inner-circle{
    width:50px;
    background:#84271C;
    border-radius:100%;
    border:25px solid #191210;
  }
  .special{
    position:absolute;
    z-index:0;
    width:100px;
    display:grid;
    grid-template-columns: repeat(2, 1fr);
  }
  .special > div{
    background:#191210;
    border-bottom:20px solid #ECA03D;
  }
  .special > div:nth-child(1){
    border-radius:0 0 0 100%;
    border-left: 20px solid #ECA03D;
  }
  .special > div:nth-child(2){
    border-radius:0 0 100% 0;
    border-right: 20px solid #ECA03D;
  }
  .left{
    top:150px;
    left:50px;
  }
  .right{
    top:50px;
    transform: rotate(180deg);
    right:50px;
  }
Enter fullscreen mode Exit fullscreen mode
Collapse
 
j471n profile image
Jatin Sharma • Edited

I wish I could code that fast, that's just a timelapse video of the code. It is just to demonstrate that code works with 100% accuracy.

There is no problem with longer solution. In CSS Battle we try to keep the code as short as possible that's all.