Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

CSS3 match shape in 3d (top of cube)

CSS3 match shape in 3d (top of cube)

Problem

I am not good in math and geometry, so I would love if someone could help me with creating the following shape:

So basically the shape exists out of 3 rectangles, I got the first two working perfect with transform matrix, but I can't get the last one to match the shape (see link above for img)

JSFiddle, what I tried so far or see code below

HTML

CSS

.shape {
  perspective: 1000px;
}

.shape div {
  width: 100px;
  height: 100px;
  opacity: 0.4;
  background-color: #333;
}

.shape-rect-one {
  z-index: 100;

  transform: matrix(1, -0.40, 0, 1, 0, 0);
  -webkit-transform: matrix(1, -0.40, 0, 1, 0, 0);
}

.shape-rect-two {
  z-index: 200;

  transform: matrix(1, -0.40, 0, 1, 0, 0);
  -webkit-transform: matrix(1, 0.40, 0, 1, 0, 0);
}

.shape-rect-three {
  z-index: 300;
}​
Problem courtesy of: onlineracoon

Solution

This should create the diamond shape.

transform: matrix(-0.965, 0.45, -0.965, -0.45, 0, 0);
-webkit-transform: matrix(-0.965, 0.45, -0.965, -0.45, 0, 0);
Solution courtesy of: Christopher Parsons

Discussion

View additional discussion.



This post first appeared on CSS3 Recipes - The Solution To All Your Style Problems, please read the originial post: here

Share the post

CSS3 match shape in 3d (top of cube)

×

Subscribe to Css3 Recipes - The Solution To All Your Style Problems

Get updates delivered right to your inbox!

Thank you for your subscription

×