我正在 wordpress.com 中创建一个网站,我试图弄清楚如何控制图像的放置位置?目前我只能将图像放在另一个图像的下方或上方,它看起来真的很乱。有没有办法使用 html 或 CSS 来控制坐标?最好是 html,因为我想要不同图像的不同位置。
到目前为止,这是我的图像的代码:
.container {
position: relative;
width: 400px;
}
.image {
display: block;
width: 100%;
height: auto;
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background-color: #008CBA;
}
.container:hover .overlay {
opacity: 1;
}
.projeto01 {
color: white;
font-size: 40px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
text-align: center;
}
<div class="grid-portefolio">
<div class="container">
<a href="https://en.wikipedia.org/wiki/Main\_Page"><img src="https://insert1australia.files.wordpress.com/2021/04/real-sinister-minister-14-250x250-1-1.png" class="image" alt="Albert Lee Banks Electorate"/><div class="overlay"><div class="projeto01">Albert Lee<br>Banks Electorate</div></div></a>
</div>
另请注意,我是编程的初学者。上面的代码是我在网上找到的模板和朋友的一些帮助的混合体。