Reputation: 8769
I have an isometric table setup as:
<table style="transform: rotateX(60deg) rotateZ(45deg); border-spacing: 0px">
<tr style="transform: translateY(0em)"> <!-- For first row, future rows get translated down -->
<td style="transform: translateX(0em)"> <!-- For first column, future columns get translated down -->
<div class="tile">
<div class="background"></div>
</div>
</td>
</tr>
</table>
With the following CSS:
.tile {
transform: translate3d(0em, 0em, 0em);
width: 4em;
height: 4em;
}
.background {
height: calc(28.75em);
width: calc(28.75em);
background-size: 100%;
background-image: url("/tiles/robot2/facing_north.png"), url("/tiles/plain_4/facing_east.png");
}
It produces a little robot standing on a tile as so:
However, the robot is off-centre. So, wanting to centre it I add the following CSS:
.background {
background-position-y: -3em, 0em;
}
This moves the robot up, but doesn't move the tile up, which is perfect! Except, I seem to get some cutting off of the robots head:
How can I move the robot up so that it looks to be centred on the tile without clipping off the top of it's head? I've tried overflow: visible;
to no avail.
Example:
.container {
position: relative;
z-index: 10;
}
.iso {
transform: rotateX(60deg) rotateZ(45deg);
position: absolute;
border-spacing: 0px;
left: 200.0px;
top: 100.0px;
}
.tile {
transform: translate3d(0em, 0em, 0em);
width: 4em;
height: 4em;
}
.background {
transform: rotateZ(-45deg) rotateY(-60deg) translate3d(-1.1em, -4.8em, 0em);
height: calc(23em);
width: calc(23em);
background-size: 100%;
background-image: url("https://femto.pw/us7j.png"), url("https://femto.pw/r44h.png");
background-position-y: -2.5em, 0em;
background-repeat: no-repeat;
}
<div class="container">
<table class="iso">
<tbody>
<tr class="row--5 row" style="transform: translateY(0em);">
<td class="col--5 iso_td" style="transform: translateX(0em);">
<div class="tile">
<div class="background"></div>
</div>
</td>
<td class="col--4 iso_td" style="transform: translateX(4em);">
<div class="tile">
<div class="background"></div>
</div>
</td>
</tr>
<tr class="row--4 row" style="transform: translateY(4em);">
<td class="col--5 iso_td" style="transform: translateX(0em);">
<div class="tile">
<div class="background"></div>
</div>
</td>
<td class="col--4 iso_td" style="transform: translateX(4em);">
<div class="tile">
<div class="background"></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
Upvotes: 2
Views: 134
Reputation: 819
.container {
position: relative;
z-index: 10;
}
.iso {
transform: rotateX(60deg) rotateZ(45deg);
position: absolute;
border-spacing: 0px;
left: 200.0px;
top: 100.0px;
}
.tile {
transform: translate3d(0em, 0em, 0em);
width: 4em;
height: 4em;
}
.background {
transform: rotateZ(-45deg) rotateY(-60deg) translate3d(-1.1em, -4.8em, 0em);
height: calc(23em);
width: calc(23em);
background-size: 100%;
background-image: url("https://femto.pw/r44h.png");
background-position-y: -2.5em, 0em;
background-repeat: no-repeat;
position: relative;
}
.background::before{
content: '';
position: absolute;
top: -80px;
bottom: 0;
left: 0;
right: 0;
background-image: url("https://femto.pw/us7j.png");
background-size: contain;
background-repeat: no-repeat;
}
<div class="container">
<table class="iso">
<tbody>
<tr class="row--5 row" style="transform: translateY(0em);">
<td class="col--5 iso_td" style="transform: translateX(0em);">
<div class="tile">
<div class="background"></div>
</div>
</td>
<td class="col--4 iso_td" style="transform: translateX(4em);">
<div class="tile">
<div class="background"></div>
</div>
</td>
</tr>
<tr class="row--4 row" style="transform: translateY(4em);">
<td class="col--5 iso_td" style="transform: translateX(0em);">
<div class="tile">
<div class="background"></div>
</div>
</td>
<td class="col--4 iso_td" style="transform: translateX(4em);">
<div class="tile">
<div class="background"></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
Upvotes: 2