I want the text to be right over the centre of each image, but instead it just stays above them. I'm using a div for each image and text item, and a general div to hold all of this items together. I'm sure there are more effective ways to organise this, however I'm very new to CSS and HTML.
The code I'm using:
.projects {
width: 54%;
position: relative;
margin: auto;
}
.project {
position: relative;
margin: 0 auto;
width: 100%;
max-height: 600px;
min-height: 90px;
}
.project2 {
position: relative;
margin: 0 auto;
width: 100%;
max-height: 600px;
min-height: 90px;
}
.project3 {
position: relative;
margin: 0 auto;
width: 100%;
max-height: 600px;
min-height: 90px;
}
/* Caption text */
.text {
font-family: 'Verdana';
font-weight: bold;
font-size: 36px;
color: #FBB2B4;
text-decoration: none;
padding: 8px 12px;
position: relative;
top: 45%;
width: 100%;
text-align: center;
}
.text2 {
font-family: 'Verdana';
font-weight: bold;
font-size: 36px;
color: #FBB2B4;
text-decoration: none;
padding: 8px 12px;
position: relative;
top: 45%;
width: 100%;
text-align: center;
}
.text3 {
font-family: 'Verdana';
font-weight: bold;
font-size: 36px;
color: #FBB2B4;
text-decoration: none;
padding: 8px 12px;
position: relative;
top: 45%;
width: 100%;
text-align: center;
}
<div class="projects">
<div class="project">
<div class="text">heading1</div>
<img src="https://via.placeholder.com/150/" style="width:100%">
</div>
<div class="project2">
<div class="text2">heading2</div>
<img src="https://via.placeholder.com/150/" style="width:100%">
</div>
<div class="project3">
<div class="text3">heading3</div>
<img src="https://via.placeholder.com/150/" style="width:100%">
</div>
</div>