DEV Community

Cover image for CSSBattle | #23 Boxception
Nazmuz Shakib Pranto
Nazmuz Shakib Pranto

Posted on

CSSBattle | #23 Boxception

Welcome to CSSBattle Challenges!

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


Challenge:

Boxception Challenge


Solution:

<div class="container flex bg-gold">
  <div class="green-square flex">
    <div class="lightyellow-square flex">
      <div class="gold-square bg-gold"></div>
    </div>
  </div>
</div>

<style>
  * {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
  }
  .flex {
    display: flex;
  }
  .bg-gold {
    background: #f3ac3c;
  }
  .container {
    width: 100vw;
    height: 100vh;
    justify-content: center;
    align-items: center;
  }
  .green-square {
    width: 200px;
    height: 200px;
    background: #1a4341;
    align-items: flex-end;
  }
  .lightyellow-square {
    width: 100px;
    height: 100px;
    background: #998235;
    align-items: flex-end;
    justify-content: flex-end;
  }
  .gold-square {
    width: 50px;
    height: 50px;
  }
</style>
Enter fullscreen mode Exit fullscreen mode

Key Takeaway(s):

  • using display flex can be super useful to position nested children elements to certain corners within the parent container

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

Latest comments (0)