DEV Community

Chetan
Chetan

Posted on

CSS Battle #27 - Lock Up css, html, webdev, tutorial

So this brain bending challenge requires you to be comfortable with absolute positioning and border-radius.

Goal

Alt Text

Observation of Goal

  1. For sure Margin of the body need to be zero
  2. If we observe it carefully we can see that
    1. A big circle at the bottom
    2. 2 quarters at the bottom left and top right side
    3. a small circle at top of the quarters
  3. All shapes have origin from center
  4. Red Big circle is the base then we make 2 quarters of yellow color and on top of it is again a circle of red color. Note: It is prudent to guess the size of shapes say width and height rather than manually plugging in value. (Your neurons transmit information way faster than your hands in the editor)

Solution

Combining the above observations we can figure out the code looks similar to the below code

<div class="container">
    <div> </div>
    <div> </div>
    <div> </div>
    <div> </div>
</div>
<style>
body {
    background: #E38F66;
}

.container>div {
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    position: absolute;
}


/* Big circle */

.container >div:nth-child(1) {
    border-color: #AA445F;
    border-radius: 50%;
    border-width: 100px;
    border-style: solid;
    z-index: -1;
}


/* Quarter Circle */

.container > div:nth-child(2) {
    background: #F7EC7D;
    height: 70px;
    width: 70px;
    transform: translate(0px, -70px);
    border-radius: 0 300px 0 0
}


/* Quarter Circle */

.container > div:nth-child(3) {
    background: #F7EC7D;
    height: 70px;
    width: 70px;
    transform: translate(-70px, 0px);
    border-radius: 0px 0 0 300px
}


/* Small  Inside Circle */

.container > div:nth-child(4) {
    border-color: #AA445F;
    border-radius: 50%;
    border-width: 40px;
    border-style: solid;
}
</style>
Enter fullscreen mode Exit fullscreen mode

Do let us know how much time you took to achieve the target by yourself in the comments so we can monitor our progress.

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now