How do I center a text over an in css?
when i try to move `text over image then text is move but when two images then i need to move text for every position how to solve this problem.
.container {
height: 1224px;
width: 90%;
margin: 100px auto;
}
.row {
display: flex;
gap: 20px;
justify-content: center;
align-items: center;
/* width: 50%; */
}
.category {
/* width: 50%; */
}
.image {
height: 300px;
}
.image img {
height: 100%;
width: 100%;
border-radius: 8px;
}
.title {
position: absolute;
top: 50%;
}
<div class="container">
<div class="row">
<div class="category">
<div class="image">
<img src="img1.jpeg" alt="">
</div>
<div class="title">
<h2>Title</h2>
</div>
</div>
<div class="category">
<div class="image">
<img src="img1.jpeg" alt="">
</div>
<div class="title">
<h2>Title</h2>
</div>
</div>
</div>
</div>
when i try to move `text over image then text is move but when two images then i need to move text for every position how to solve this problem.
2
Answers
always lot better to structure the page with css grid, after in 1 element of the grid you can use flex.
to "move" over, your text has to move 1 layer up, can be done if your div is relative, absolute or float.
always question of way you structure your html to have the right css to achieve what you want.
if I understand what you’re asking