html - 在其他非固定 pos 图像上叠加图像?
问题描述
有没有办法通过 ::after 伪元素将一张图片叠加在另一张图片之上?我正在做一个人事数据库作为一个学校项目,我想通过覆盖在旧奖项之上的图像来表示后续奖项。
HTML:
<div class="awardRow">
<span id="awardAbbrev" class="award2"><img src="path/to/image.png"></span>
<span id="awardAbbrev2" class="award2"><img src="path/to/image.png"></span>
<span id="awardAbbrev3" class="award2"><img src="path/to/image.png"></span>
</div>
CSS:
.award2::after {
content: url(imageToOverlay.png);
position: relative;
left: -110px;
}
我尝试了其他几种方法都无济于事。任何帮助,将不胜感激。
解决方案
我为你做了这个,通过这段代码你会明白的。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
.box {
width: 175px;
height: 175px;
color: blue;
border: 2px solid blue;
}
#box1 {
background-color: aqua;
position: absolute;
top: 228%;
left: 45%;
}
#box2 {
background-color: rgb(145, 255, 0);
position: absolute;
top: 70%;
left: 15%;
}
#box3 {
background-color: rgb(255, 0, 68);
position: absolute;
top: 147%;
left: 30%;
}
#box4 {
background-color: rgb(255, 238, 0);
}
.container {
display: flex;
position: relative;
}
</style>
</head>
<body>
<div class="container">
<div class="box" id="box1"></div>
<div class="box" id="box2"></div>
<div class="box" id="box3"></div>
<div class="box" id="box4"></div>
</div>
</body>
</html>
推荐阅读
- javascript - Chrome扩展获取所有分页页面项目javascript
- python-3.x - Python项目中,创建发行版时如何打包已安装的库?
- python - StandardScaler 给出非均匀标准偏差
- react-native - 有时阿波罗查询不会发生;我被迫退出应用程序并重新打开
- python - Discord.py 正常运行时间
- c - 如何在C中打印每个第二个数字
- aws-lambda - AWS API Gateway Lambda 错误正则表达式不起作用?
- jquery - 服务器端验证似乎在 SpringBoot 2.3.1.RELEASE 中不起作用
- hybris - 找不到此本地主机页面:Hybris
- android - 如何从 android studio 下载管理器中的 google drive 链接下载文件?