0
<div class="store_module" id="@store.ID" style="
    margin-left: 0px;
    overflow: hidden;
    display: block;
    background-color: #343233;
    cursor: pointer
  ">
<div class="store_image" style="
    float: left;
    overflow: hidden;
    width: 100px
">
<img src="@store.ImageLogo" style="
  display: block; 
  margin: auto;
"/>
</div>
</div>

Why can't I center the logo picture vertically? It must be very easy, but I really can't find the answer.

Cody Guldner
  • 2,888
  • 1
  • 25
  • 36
hammerpath
  • 45
  • 9

1 Answers1

1

Give its parent display: table; and the image display: table-cell; and vertical-align: middle;:

.store_image {
    display: table;
}
.store_image img {
    display: table-cell;
    vertical-align: middle;
}

By the way, there are plenty of sites, even questions on SO, describing this problem. (Proof)

EDIT:

According to this you can leave out the display: rules.

11684
  • 7,356
  • 12
  • 48
  • 71