You can change the default display type of the image to inline-block
and create a full-height pseudo-element beside that which is inline-block
too.
Then align the inline elements vertically by vertical-align: middle;
and get the image to the center by using text-align: center;
for the parent #box
.
Also, there will be a white space character between inline(-block) elements you have to remove it. you can refer my answer to do that.
Here you go:
#box {
/* Other styles here... */
text-align: center; /* align the inline(-block) elements horizontally */
font: 0/0 a; /* remove the gap between inline(-block) elements */
}
#box:after { /* create a full-height inline block pseudo=element */
content: ' ';
display: inline-block;
vertical-align: middle; /* vertical alignment of the inline element */
height: 100%;
}
#box img {
display: inline-block;
vertical-align: middle; /* vertical alignment of the inline element */
}
WORKING DEMO
For further details you can refer to my answer here.