重叠多个内联图像
您的目标是呈现一组类似于以下内容的重叠图像:
您当前的代码:
<code class="css">.avatar img { border-radius: 50%; position: relative; left: -5px; z-index: 1; }</code>
<code class="html"><div class="avatars"> <span class="avatar"> <img src="/static/imghwm/default1.png" data-src="https://picsum.photos/70" class="lazy" style="max-width:90%" style="max-width:90%" alt="如何在不进行 Z-Index 操作的情况下有效地重叠多个内联图像?" > </span> <span class="avatar"> <img src="/static/imghwm/default1.png" data-src="https://picsum.photos/50" class="lazy" style="max-width:90%" style="max-width:90%" alt="如何在不进行 Z-Index 操作的情况下有效地重叠多个内联图像?" > </span> <span class="avatar"> <img src="/static/imghwm/default1.png" data-src="https://picsum.photos/20" class="lazy" style="max-width:90%" style="max-width:90%" alt="如何在不进行 Z-Index 操作的情况下有效地重叠多个内联图像?" > </span> <span class="avatar"> <img src="/static/imghwm/default1.png" data-src="https://picsum.photos/100" class="lazy" style="max-width:90%" style="max-width:90%" alt="如何在不进行 Z-Index 操作的情况下有效地重叠多个内联图像?" > </span> <!-- Variable amount more avatars --> </div> <p>4 People</p></code>
但是,由于您可能遇到的图像数量不同,此方法变得不切实际。
解决方案:
利用 Flexbox 并反转排序以消除 z-index 操作的需要:
<code class="css">.avatars { display: inline-flex; flex-direction: row-reverse; } .avatar { position: relative; border: 4px solid #fff; border-radius: 50%; overflow: hidden; width: 100px; } .avatar:not(:last-child) { margin-left: -60px; } .avatar img { width: 100%; display: block; }</code>
<code class="html"><div class="avatars"> <span class="avatar"> <img src="/static/imghwm/default1.png" data-src="https://picsum.photos/70" class="lazy" alt="如何在不进行 Z-Index 操作的情况下有效地重叠多个内联图像?" > </span> <span class="avatar"> <img src="/static/imghwm/default1.png" data-src="https://picsum.photos/80" class="lazy" alt="如何在不进行 Z-Index 操作的情况下有效地重叠多个内联图像?" > </span> <span class="avatar"> <img src="/static/imghwm/default1.png" data-src="https://picsum.photos/90" class="lazy" alt="如何在不进行 Z-Index 操作的情况下有效地重叠多个内联图像?" > </span> <span class="avatar"> <img src="/static/imghwm/default1.png" data-src="https://picsum.photos/100" class="lazy" alt="如何在不进行 Z-Index 操作的情况下有效地重叠多个内联图像?" > </span> </div></code>
此解决方案灵活对齐图像,无论图像数量如何,都能确保正确排列。
以上是如何在不进行 Z-Index 操作的情况下有效地重叠多个内联图像?的详细内容。更多信息请关注PHP中文网其他相关文章!

Goofonts是由开发人员和设计师丈夫签名的附带项目,它们都是版式的忠实拥护者。我们一直在标记Google

学习如何构建GraphQL API可能具有挑战性。但是您可以学习如何在10分钟内使用GraphQL API!碰巧的是,我得到了完美的

这里是Yuanchuan的一些合法CSS骗局。有此CSS属性偏移路径。曾几何时,它被称为Motion-Path,然后被更名。我


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

安全考试浏览器
Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

Dreamweaver Mac版
视觉化网页开发工具

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。