javascript - 使用 ng-repeat 定位 3d 对象

标签 javascript html css angularjs 3d

最终结果应该类似于所附图片 ( Link to illustation )。

图片的每个部分都是在 Illustrator 中绘制的单独的 png 图像,每个图像都有自己的 CSS 类。

我的问题是如何设置每个 block (png) 的位置以使它们看起来像这样。 我可以使用哪些 CSS 属性来定位它们。

我还意识到它们不能垂直居中,因为那样它们就不会出现在彼此的中间。

我之前使用 ng-repeat 来绘制圆圈(作为圆形 div),但后来我得到的所有圆圈都只有一个维度。

有什么想法可以做到这一点以及我在做这件事时需要牢记什么?

Fiddle is here: https://jsfiddle.net/tyt4ft3g/1/

最佳答案

无论您尝试过什么,都是绝对正确的,并且是实现该目标的最佳方式。

基本上,您必须为所有 img 元素提供 position: absolute 并具有共同的 position: relative 父级。您必须使用 rightbottom 属性正确定位它们,以便每个图像都显示在其前任图像的中心。

此外,为顶部的图像提供更高的 z-index(即左侧较小的图像应具有比右侧图像更高的 z-index,按降序排列)。

已更新 fiddle .

引用代码以获得更好的视角:

.parent {
  width: 300px;
  height: 200px;
  position: relative;
}

.copper {
  height: 30px;
  right: 72px;
  bottom: 28px;
  position: absolute;
  z-index: 3;
  content: url(http://i.imgur.com/LeIGPou.png);
}

.ins {
  height: 60px;
  right: 37px;
  bottom: 16px;
  position: absolute;
  z-index: 2;
  content: url(http://i.imgur.com/3bMaW3t.png);
}

.power {
  height: 70px;
  right: 0;
  bottom: 16px;
  position: absolute;
  z-index: 1;
  content: url(http://i.imgur.com/jFYquAI.png);
}
<div class="parent">
  <img class="copper">
  <img class="ins">
  <img class="power">
</div>

关于javascript - 使用 ng-repeat 定位 3d 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43001072/

相关文章:

css - 是否有针对 Firefox 错误 : inline-block + first-letter with changed size 的 CSS 解决方法

jquery - jsPdf 给 pdf 页面添加边距

html - 在 ionic <ion-item> 之间添加自定义规则

html - 可扩展站点,菜单背景消失

javascript - Jquery 更改功能不起作用?

javascript - 简单的 Javascript 在 FireFox 中不起作用(但在所有其他浏览器中都起作用)

javascript - 如何使链接被识别

javascript - 正则表达式 ['!@#$%*\]\[()-=_+{}:\";?,.\/A-Za-z0-9\s] 允许 < 字符

javascript - 想要打印 json 对象的循环但无法从 json 对象访问值

javascript - JQuery 无法识别的表达式包含选择器