【问题标题】:Center image vertically html [duplicate]垂直居中图像html [重复]
【发布时间】:2013-03-29 12:32:43
【问题描述】:
<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>

为什么我不能垂直居中徽标图片?一定很简单,但我实在找不到答案。

【问题讨论】:

    标签: html css image


    【解决方案1】:

    给它的父display: table;和图像display: table-cell;vertical-align: middle;

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

    顺便说一句,有很多网站,甚至关于 SO 的问题都描述了这个问题。 (Proof)

    编辑:

    根据this,您可以省略display: 规则。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-04
      • 1970-01-01
      • 1970-01-01
      • 2010-12-30
      • 1970-01-01
      • 2011-10-06
      相关资源
      最近更新 更多