DEV Community

Cover image for CSSBattle | #19 Cube
Nazmuz Shakib Pranto
Nazmuz Shakib Pranto

Posted on

CSSBattle | #19 Cube

Welcome to CSSBattle Challenges!

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


Challenge:

Cube Challenge


Solution:

<div class="container">
  <div class="diag-square"></div>
  <div class="rect skew-left"></div>
  <div class="rect skew-right"></div>
</div>
<style>
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  .container {
    width: 100vw;
    height: 100vh;
    background: #0B2429;
    position: relative;
  }
  .diag-square {
    position: absolute;
    width: 100px;
    height: 100px;
    background: #F3AC3C;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -15%) rotate(45deg) 
  }
  .rect {
    position: absolute;
    width: 70px;
    height: 70px;
    top: 50%;
    left: 50%;
  }
  .skew-left {
    background: #1A4341;
    transform: translate(0px, -70px) skew(0deg, 45deg);
  }
  .skew-right {
    background: #998235;
    transform: translate(-70px, -70px) skew(0deg, -45deg) ;
  }
</style>
Enter fullscreen mode Exit fullscreen mode

Key Takeaway(s):

  • using skew property within transform in CSS to skew rectangle or square like shapes

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

Top comments (0)