DEV Community 👩‍💻👨‍💻

Cover image for CSSBattle | #9 Tesseract
Nazmuz Shakib Pranto
Nazmuz Shakib Pranto

Posted on

CSSBattle | #9 Tesseract

Welcome to CSSBattle Challenges!

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


Challenge:

Tesseract Challenge


Solution:

<div class="container">
  <div class="outer-rect"></div>
  <div class="outer-transparent-square"></div>
  <div class="inner-fill-square"></div>
  <div class="inner-circle"></div>
</div>

<style>
  * {
    box-sizing: border-box;
    padding: 0;
    margin: 0;
  }
  .container {
    width: 100%;
    height: 100%;
    background: #222730;
    position: relative;
  }
  .outer-rect,
  .outer-transparent-square,
  .inner-fill-square,
  .inner-circle {
    top: 50%;
    left: 50%;
    position: absolute;
  }
  .outer-rect {
    width: 100%;
    height: 150px;
    background: #4caab3;
    transform: translate(-50%, -50%);
  }
  .outer-transparent-square {
    width: 250px;
    height: 250px;
    background: #222730;
    transform: translate(-50%, -50%) rotate(45deg);
  }
  .inner-fill-square {
    width: 150px;
    height: 150px;
    background: #4caab3;
    transform: translate(-50%, -50%) rotate(45deg);
  }
  .inner-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #393e46;
    transform: translate(-50%, -50%);
  }
</style>
Enter fullscreen mode Exit fullscreen mode

Key Takeaway(s):

  • using relative and absolute positioning to create relationships between parent and children elements

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

Top comments (0)

🌚 Life is too short to browse without dark mode