Compass pointer or needle shape using 3D transforms
suggest changeCSS
div.needle {
margin: 100px;
height: 150px;
width: 150px;
transform: rotateY(85deg) rotateZ(45deg);
/* presentational */
background-image: linear-gradient(to top left, #555 0%, #555 40%, #444 50%, #333 97%);
box-shadow: inset 6px 6px 22px 8px #272727;
}
HTML
<div class='needle'></div>
In the above example, a needle or compass pointer shape is created using 3D transforms. rotate() and rotateZ() turn the element in the screen plane and, by themselves, produce a diamond rather than a needle. rotateY() rotates around the vertical axis and foreshortens the element horizontally, which is what makes it look like a needle. The closer that Y rotation is to 90 degrees, the thinner the element looks. Perspective is not set here, so the foreshortening is the browser’s default flattening of the rotated plane.
The output of the above example would be a needle resting on its tip. For creating a needle that is resting on its base, the rotation should be along the X-axis instead of along Y-axis. So the transform property’s value would have to be something like rotateX(85deg) rotateZ(45deg);.
This pen uses a similar approach to create something that resembles the Safari logo or a compass dial.
Screenshot of element with no transform:
Screenshot of element with only 2D transform:
Screenshot of element with 3D transform: