It is convenient for isometric grids to start at the top like this:
I have the following code to draw a "3d" isometric box:
body {
display: flex;
justify-content: center;
align-items: center;
}
.plane {
position: relative;
width: 600px;
height: 600px;
}
.container {
position: absolute;
width: 0;
height: 0;
}
.left {
background-color: #3e8fe1;
height: var(--width);
width: var(--height);
transform-origin: 0 0;
transform: rotate(90deg) skewX(-30deg) scaleY(0.864);
}
.right {
position: relative;
background-color: #2870bd;
height: var(--height);
width: var(--length);
transform-origin: 0 0;
transform: rotate(-30deg) skewX(-30deg) scaleY(0.864);
bottom: var(--width);
}
.top {
position: relative;
background-color: #80bdfe;
height: var(--length);
width: var(--width);
transform-origin: 0 0;
transform: rotate(210deg) skew(-30deg) scaleY(0.864);
bottom: calc(var(--width) + var(--height));
}
<body>
<div class="plane">
<div class="container" style="--width: 50px; --length: 200px; --height: 100px; left: 150px; top: 150px;">
<div class="left"></div>
<div class="right"></div>
<div class="top"></div>
</div>
</div>
</body>
This works, but is there any way to make it so that increasing the --width
, --length
, and --height
CSS variables would grow the box in the opposite directions that they are currently growing in?
That is, --width
is currently growing front to back, but should grow back to front (such that increasing it makes it extrude towards you instead of away from you)
Similarly, increasing the --height
should make it grow up, not down.
And lastly, increasing the --length
should make it grow towards the "camera", and not away from it, as it currently does.
x
, andy
. To which axes do the nameswidth
,length
, andheight
refer? I'd assumeheight
would be the implicitz
axis, but assumptions are often flawed. – Instrumentalismheight
would be thez
axis. And let's see..length
would be they
axis andwidth
would be thex
axis I believe – Prussian