【发布时间】:2021-01-20 07:03:48
【问题描述】:
我知道必须查看 img 链接可能很糟糕,但请帮忙。我真的很需要它。
发布的图片包含我想要实现的目标,但是我希望能够通过命令<div> 来移动整个拼贴画。虽然,现在,我可以移动图像,但这包括每次我必须在图像拼贴上方添加一些东西时都必须单独更改绝对定位。此外,图像需要以特定顺序相互堆叠。这是我的代码:
body {
margin: 0;
}
h1 {
margin: 0;
text-align: center;
color: #dbdbdb;
font-family: 'Dosis', sans-serif;
font-size: 4rem;
}
.title-holder {
background-color: #333333;
margin: 0;
padding-top: 7rem;
padding-bottom: 7rem;
}
.photo-holder {
height: 60rem;
background-color: #333333;
}
.pic {
width: 20%;
border-radius: 100%;
position: absolute;
display: inline-block;
}
.pic:hover {
z-index: 15;
width: 22%;
}
.camera {
right: 24rem;
top: 30.5rem;
z-index: 3;
}
.coffee {
top: 14rem;
right: 25rem;
z-index: 7;
}
.flower {
right: 38rem;
top: 42rem;
z-index: 6;
width: 22rem;
}
.plane {
top: 25rem;
right: 40rem;
z-index: 4;
}
.plane:hover {
width: 25%;
}
.wing {
left: 25rem;
top: 15rem;
z-index: 5;
}
.bike {
left: 20rem;
top: 32rem;
z-index: 5;
}
<link href="https://fonts.googleapis.com/css2?family=Dosis:wght@300&display=swap" rel="stylesheet">
<section>
<div class="name-holder">
<h3>Mohd Yusuf Patrawala</h3>
</div>
</section>
<div class="title-holder">
<h1>Those Things that make me fall in Love.</h1>
</div>
<div class="photo-holder">
<img class="pic bike hvr-grow" src="https://picsum.photos/200" alt="">
<img class="pic coffee hvr-bounce-in" src="https://picsum.photos/200" alt="">
<img class="pic flower hvr-bounce-in" src="https://picsum.photos/200" alt="">
<img class="pic plane hvr-bounce-in" src="https://picsum.photos/200" alt="">
<img class="pic wing hvr-grow" src="https://picsum.photos/200" alt="">
<img class="pic camera hvr-grow" src="https://picsum.photos/200" alt="">
</div>
</section>
【问题讨论】:
-
如果图像的来源不是本地硬盘上的文件,而是互联网上的图像,那么提供帮助会容易得多。您可以使用 placeholder.com 或 dummyimage.com 之类的服务,或者使用 Stack Overflow 上的编辑器上传图片,并使用其提供的 imgur.com 地址。
标签: html css image positioning absolute