I am trying to vertically align a child element within its parent element
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<style type="text/css">
#body {
font-family: sans-serif, arial, 'Roboto';
}
#outer {
width: 280px;
background-color: white;
height: 253px;
background-color: #f0f0f0;
}
.imgbox {
height: 174px;
width: 270px;
overflow: hidden;
display: table;
margin: 0 auto;
background-color: black;
text-align: center;
}
.img_content {
max-height: 174px;
max-width: 270px;
margin: 0 auto;
vertical-align: middle;
display: table-cell;
}
.titlebox {
max-width: 270px;
text-align: center;
}
.title {
font-weight: 900;
font-size: 14px;
}
</style>
</head>
<body>
<div id="outer">
<div class="imgbox">
<img class="img_content" src="http://lorempixel.com/700/100" alt="test image">
</div>
<div class="titlebox">
<p class="title">Lorem ipsum Lorem</p>
</div>
</div>
</body>
</html>
Can anyone explain why the img_content class doesn't vertically align in the middle of the imgbox class when the image exceeds the width?