DEV Community

Cover image for CSSBattle | #7 Leafy Trail
Nazmuz Shakib Pranto
Nazmuz Shakib Pranto

Posted on

3 2

CSSBattle | #7 Leafy Trail

Welcome to CSSBattle Challenges!

In this short article, I go through my solution for CSSBattle - #7 Leafy Trail challenge. Please refer to the code snippet below to get a better insight into my thought processes and the implementation detail.


Challenge:

Leafy Trail Challenge


Solution:

<div class="container">
  <div class="leaf left"></div>
  <div class="leaf center"></div>
  <div class="leaf right"></div>
</div>

<style>
  * {
    box-sizing: border-box;
    padding: 0;
    margin: 0;
  }
  .container {
    width: 100%;
    height: 100%;
    background: #0B2429;
    position: relative;
  }
  .leaf {
    width: 150px;
    height: 150px;
    border-top-left-radius: 100px;
    border-bottom-right-radius: 100px;
    position: absolute;
    top: 50%;
    left: 50%;
  }
  .left {
    background: #1A4341;
    transform: translate(calc(-50% + -50px), -50%) 
  }
  .center {
    background: #998235;
    transform: translate(-50%, -50%)
  }
  .right {
    background: #F3AC3C;
    transform: translate(calc(-50% + 50px), -50%);
  }
</style>
Enter fullscreen mode Exit fullscreen mode

Key Takeaway(s):

  • using top: 50% and left: 50% and transform: translate(-50%, -50%) to center absolute positioned elements
  • adjusting border radius properties to create a leaf like element

As always, I welcome any feedback or questions regarding the implementation detail of the challenge. Otherwise, I hope this was useful!

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay