I have 3 inline block elements, an image and two pieces of text. I would like to modify the class for only the image such that it is middle aligned while the other two text blocks remain top aligned. It seems to only work if I set .subImg
to have vertical-align:top;
and .subsection
to have vertical-align:middle;
but not the the other way around. Why is this and how could I fix it? Thanks
Here's the code:
HTML
<div id="about">
<div class="section">
<img class="subImg" src="https://cdn.photographylife.com/wp-content/uploads/2014/06/Nikon-D810-Image-Sample-6.jpg" alt="image">
<div class="subsection">
<h2>Blah</h2>
<hr>
<p>blah<br>blah<br>blah<br>blah<br>blah<br>blah<br></p>
</div>
<div class="subsection">
<h2>Blah</h2>
<hr>
<p> blah<br>blah<br>blah<br>blah<br>blah<br>blah<br>blah<br>
</p>
</div>
</div>
</div>
CSS
.section{
width: 100%;
text-align: center;
background-color:#fdfdfd;
}
.subsection{
vertical-align: top;
margin: 20px;
text-align: left;
display: inline-block;
max-width: 20%;
}
.subImg{
vertical-align: middle;
margin: 20px;
text-align: left;
display: inline-block;
max-width: 20%;
}