DEV Community

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

Posted on

5 2

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!

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

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

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

Okay