html - 如何将多个图像垂直放置在单个图像的顶部
问题描述
我将多个图像(一个在其他图像下方)放置在单个图像的顶部。要放置在顶部的图像数量来自后端,因此我应用于将一张图像放置在另一张图像上的 css 仅适用于一张图像,不适用于其他图像。怎么做?因为我在顶部只得到一张图片。基本上三个前景图像需要垂直定位在一个背景图像上。
<div class="row">
{% for a in count %}
<div class="column">
<img src="{{ url_for('static', filename='building.jpg') }}" id="backgroundimage" title="Total Floors: 3 Total Rooms: 6" />
<p>{{ a }}</p>
{% for b in rows%}
<img src="{{ url_for('static', filename='building.jpg') }}" id="foregroundimage" title="Total Floors: 3 Total Rooms: 6" />
{% endfor %}
</div>
{% endfor %}
解决方案
如果我理解你想要做什么,我会在 Jinja2 loop.index函数的帮助下使用 CSS z-index 值。
所以试试这个:
<div class="row">
{% for a in count %}
<div class="column">
<img src="{{ url_for('static', filename='building.jpg') }}" id="backgroundimage" title="Total Floors: 3 Total Rooms: 6" />
<p>{{ a }}</p>
{% for b in rows%}
<img style="z-index: -{{loop.index}};" src="{{ url_for('static', filename='building.jpg') }}" id="foregroundimage" title="Total Floors: 3 Total Rooms: 6" />
{% endfor %}
</div>
{% endfor %}
值得注意。
循环索引
- 循环的当前迭代。(1个索引)
循环.index0
- 循环的当前迭代。(0 索引)
推荐阅读
- javascript - D3 Stacked Bar Chart: Bars Overlap
- r - Calculating rowMean ignoring 0 values
- r - Potential issue in svylogrank test results
- c++17 - 向量
..事情超出范围?它是如何工作的? - python - How to fix "ModuleNotFoundError: No module named '__builtin__' " in pycharm
- android - Flutter assets image not find
- sql - Oracle/SQL Power Bi DirectQuery 指令错误“当前不支持此本机数据库查询。”
- flutter - Flutter 刷新状态小部件
- tensorflow - 什么时候应该使用 tf.function 装饰器
- javascript - javascript-如何通过在 Chrome 中调试在一个 if 语句中查看每个条件的结果?