css 非 iso-metric children 等距视图
css isometric view with non iso-metric children
我正在使用 transform: rotateX(60deg) rotateY(0deg) rotateZ(-45deg);
使元素看起来像是在等距透视中。我想知道如何恢复某些 children 的效果,以便它们共享协调系统但正常对齐。我试图以相同的方式向后旋转 children 但它的工作方式似乎有所不同。有什么想法吗?
.iso {
transform: rotateX(60deg) rotateY(0deg) rotateZ(-45deg);
transform-style: preserve-3d;
position: relative;
height: 20rem;
width: 20rem;
text-align: center;
margin: 0 auto;
background-color: tomato;
box-sizing: border-box;
padding: 2rem;
}
.marker {
position: absolute;
left: 10rem;
top: 15rem;
transform: rotateX(-60deg) rotateY(0deg) rotateZ(45deg);
}
<div class="iso">
<h3>I'm also iso aligned</h3>
<div class="marker">
<svg xmlns='http://www.w3.org/2000/svg' height='30' width='27' viewBox='0 0 25 30'><path stroke="#FFFFFF" stroke-width="2" fill='29434e' d='M13.6363636,0.272727273 C16.6363636,0.272727273 19.6363636,1.63636364 21.8181818,3.81818182 C24,6.27272727 25.3636364,9 25.3636364,12.2727273 C25.3636364,15.5454545 24,19.0909091 21.8181818,21.2727273 L13.6363636,29.7272727 L5.45454545,21.2727273 C3.27272727,19.0909091 1.90909091,15.8181818 1.90909091,12.2727273 C1.90909091,9 3,6.27272727 5.45454545,3.81818182 C7.63636364,1.63636364 10.6363636,0.272727273 13.6363636,0.272727273 Z'/></svg></div>
</div>
您应该将 transform-origin
更改为底部,然后使用如下相反的转换。您不仅应该反转值,还应该反转顺序。
添加了一个额外的未转换的标记以与
进行比较
.iso {
transform: rotateX(60deg) rotateY(0deg) rotateZ(-45deg);
transform-style: preserve-3d;
position: relative;
height: 20rem;
width: 20rem;
text-align: center;
margin: 0 auto;
background-color: tomato;
box-sizing: border-box;
padding: 2rem;
}
.marker {
position: absolute;
left: 10rem;
top: 15rem;
transform: rotateZ(45deg) rotateY(0deg) rotateX(-60deg);
transform-origin:bottom center;
}
.compare {
position:absolute;
left: 15rem;
top: 10rem;
}
<div class="iso">
<h3>I'm also iso aligned</h3>
<div class="marker">
<svg xmlns='http://www.w3.org/2000/svg' height='30' width='27' viewBox='0 0 25 30'><path stroke="#FFFFFF" stroke-width="2" fill='29434e' d='M13.6363636,0.272727273 C16.6363636,0.272727273 19.6363636,1.63636364 21.8181818,3.81818182 C24,6.27272727 25.3636364,9 25.3636364,12.2727273 C25.3636364,15.5454545 24,19.0909091 21.8181818,21.2727273 L13.6363636,29.7272727 L5.45454545,21.2727273 C3.27272727,19.0909091 1.90909091,15.8181818 1.90909091,12.2727273 C1.90909091,9 3,6.27272727 5.45454545,3.81818182 C7.63636364,1.63636364 10.6363636,0.272727273 13.6363636,0.272727273 Z'/></svg></div>
</div>
<!-- to compare with -->
<svg class="compare" xmlns='http://www.w3.org/2000/svg' height='30' width='27' viewBox='0 0 25 30'><path stroke="#FFFFFF" stroke-width="2" fill='29434e' d='M13.6363636,0.272727273 C16.6363636,0.272727273 19.6363636,1.63636364 21.8181818,3.81818182 C24,6.27272727 25.3636364,9 25.3636364,12.2727273 C25.3636364,15.5454545 24,19.0909091 21.8181818,21.2727273 L13.6363636,29.7272727 L5.45454545,21.2727273 C3.27272727,19.0909091 1.90909091,15.8181818 1.90909091,12.2727273 C1.90909091,9 3,6.27272727 5.45454545,3.81818182 C7.63636364,1.63636364 10.6363636,0.272727273 13.6363636,0.272727273 Z'/></svg>
相关问题以更好地理解顺序的重要性:
我正在使用 transform: rotateX(60deg) rotateY(0deg) rotateZ(-45deg);
使元素看起来像是在等距透视中。我想知道如何恢复某些 children 的效果,以便它们共享协调系统但正常对齐。我试图以相同的方式向后旋转 children 但它的工作方式似乎有所不同。有什么想法吗?
.iso {
transform: rotateX(60deg) rotateY(0deg) rotateZ(-45deg);
transform-style: preserve-3d;
position: relative;
height: 20rem;
width: 20rem;
text-align: center;
margin: 0 auto;
background-color: tomato;
box-sizing: border-box;
padding: 2rem;
}
.marker {
position: absolute;
left: 10rem;
top: 15rem;
transform: rotateX(-60deg) rotateY(0deg) rotateZ(45deg);
}
<div class="iso">
<h3>I'm also iso aligned</h3>
<div class="marker">
<svg xmlns='http://www.w3.org/2000/svg' height='30' width='27' viewBox='0 0 25 30'><path stroke="#FFFFFF" stroke-width="2" fill='29434e' d='M13.6363636,0.272727273 C16.6363636,0.272727273 19.6363636,1.63636364 21.8181818,3.81818182 C24,6.27272727 25.3636364,9 25.3636364,12.2727273 C25.3636364,15.5454545 24,19.0909091 21.8181818,21.2727273 L13.6363636,29.7272727 L5.45454545,21.2727273 C3.27272727,19.0909091 1.90909091,15.8181818 1.90909091,12.2727273 C1.90909091,9 3,6.27272727 5.45454545,3.81818182 C7.63636364,1.63636364 10.6363636,0.272727273 13.6363636,0.272727273 Z'/></svg></div>
</div>
您应该将 transform-origin
更改为底部,然后使用如下相反的转换。您不仅应该反转值,还应该反转顺序。
添加了一个额外的未转换的标记以与
进行比较.iso {
transform: rotateX(60deg) rotateY(0deg) rotateZ(-45deg);
transform-style: preserve-3d;
position: relative;
height: 20rem;
width: 20rem;
text-align: center;
margin: 0 auto;
background-color: tomato;
box-sizing: border-box;
padding: 2rem;
}
.marker {
position: absolute;
left: 10rem;
top: 15rem;
transform: rotateZ(45deg) rotateY(0deg) rotateX(-60deg);
transform-origin:bottom center;
}
.compare {
position:absolute;
left: 15rem;
top: 10rem;
}
<div class="iso">
<h3>I'm also iso aligned</h3>
<div class="marker">
<svg xmlns='http://www.w3.org/2000/svg' height='30' width='27' viewBox='0 0 25 30'><path stroke="#FFFFFF" stroke-width="2" fill='29434e' d='M13.6363636,0.272727273 C16.6363636,0.272727273 19.6363636,1.63636364 21.8181818,3.81818182 C24,6.27272727 25.3636364,9 25.3636364,12.2727273 C25.3636364,15.5454545 24,19.0909091 21.8181818,21.2727273 L13.6363636,29.7272727 L5.45454545,21.2727273 C3.27272727,19.0909091 1.90909091,15.8181818 1.90909091,12.2727273 C1.90909091,9 3,6.27272727 5.45454545,3.81818182 C7.63636364,1.63636364 10.6363636,0.272727273 13.6363636,0.272727273 Z'/></svg></div>
</div>
<!-- to compare with -->
<svg class="compare" xmlns='http://www.w3.org/2000/svg' height='30' width='27' viewBox='0 0 25 30'><path stroke="#FFFFFF" stroke-width="2" fill='29434e' d='M13.6363636,0.272727273 C16.6363636,0.272727273 19.6363636,1.63636364 21.8181818,3.81818182 C24,6.27272727 25.3636364,9 25.3636364,12.2727273 C25.3636364,15.5454545 24,19.0909091 21.8181818,21.2727273 L13.6363636,29.7272727 L5.45454545,21.2727273 C3.27272727,19.0909091 1.90909091,15.8181818 1.90909091,12.2727273 C1.90909091,9 3,6.27272727 5.45454545,3.81818182 C7.63636364,1.63636364 10.6363636,0.272727273 13.6363636,0.272727273 Z'/></svg>
相关问题以更好地理解顺序的重要性: