DEV Community

Cover image for CSSBattle | #28 Cups & Balls
Nazmuz Shakib Pranto
Nazmuz Shakib Pranto

Posted on

1 1

CSSBattle | #28 Cups & Balls

Welcome to CSSBattle Challenges!

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


Challenge:

Cups & Balls Challenge


Solution:

<div class="container">
  <div class="box">
    <div class="ball bg-lemon-ginger"></div>
    <div class="cup bg-yellow-orange"></div>
    <div class="cup bg-lemon-ginger"></div>
    <div class="ball bg-yellow-orange"></div>
    <div class="cup bg-yellow-orange upside-down"></div>
    <div class="ball bg-lemon-ginger "></div>
    <div class="ball bg-yellow-orange"></div>
    <div class="cup bg-lemon-ginger upside-down"></div>
  </div>
</div>

<style>
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  .container {
    background: #1A4341;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .bg-yellow-orange {
    background: #F3AC3C;
  }
  .bg-lemon-ginger {
    background: #998235;
  }
  .upside-down {
    transform: rotate(180deg);
  }
  .box {
    width: calc(50px + 50px + 50px + 50px + 60px);
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
  }
  .ball {
    width: 50px;
    height: 50px;
    border-radius: 50%;
  }
  .cup {
    width: 50px;
    height: 50px;
    border-top-left-radius: 50px;
    border-top-right-radius: 50px;
  }
</style>
Enter fullscreen mode Exit fullscreen mode

Key Takeaway(s):

  • using display: flex to align items both vertically and horizontally
  • using gap property to create equal spacing between flex children elements

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

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

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

Okay