img在div中居中

59 篇文章 0 订阅

http://jsfiddle.net/kizu/4RPFa/4570/

<div class=frame>
    <span class="helper"></span><img src="https://i-blog.csdnimg.cn/blog_migrate/5bc7ff3bfb2bb09e7d665a976e7e7ec1.png" height=250 />
</div>
<div class=frame>
    <span class="helper"></span><img src="https://i-blog.csdnimg.cn/blog_migrate/5bc7ff3bfb2bb09e7d665a976e7e7ec1.png" height=25 />
</div>
<div class=frame>
    <span class="helper"></span><img src="https://i-blog.csdnimg.cn/blog_migrate/5bc7ff3bfb2bb09e7d665a976e7e7ec1.png" height=23 />
</div>
<div class=frame>
    <span class="helper"></span><img src="https://i-blog.csdnimg.cn/blog_migrate/5bc7ff3bfb2bb09e7d665a976e7e7ec1.png" height=21 />
</div>
<div class=frame>
    <span class="helper"></span><img src="https://i-blog.csdnimg.cn/blog_migrate/5bc7ff3bfb2bb09e7d665a976e7e7ec1.png" height=19 />
</div>
<div class=frame>
    <span class="helper"></span>
    <img src="https://i-blog.csdnimg.cn/blog_migrate/5bc7ff3bfb2bb09e7d665a976e7e7ec1.png" height=17 />
</div>
<div class=frame>
    <span class="helper"></span>
    <img src="https://i-blog.csdnimg.cn/blog_migrate/5bc7ff3bfb2bb09e7d665a976e7e7ec1.png" height=15 />
</div>
<div class=frame>
    <span class="helper"></span>
    <img src="https://i-blog.csdnimg.cn/blog_migrate/5bc7ff3bfb2bb09e7d665a976e7e7ec1.png" height=13 />
</div>
<div class=frame>
    <span class="helper"></span>
    <img src="https://i-blog.csdnimg.cn/blog_migrate/5bc7ff3bfb2bb09e7d665a976e7e7ec1.png" height=11 />
</div>
<div class=frame>
    <span class="helper"></span>
    <img src="https://i-blog.csdnimg.cn/blog_migrate/5bc7ff3bfb2bb09e7d665a976e7e7ec1.png" height=9 />
</div>
<div class=frame>
    <span class="helper"></span>
    <img src="https://i-blog.csdnimg.cn/blog_migrate/5bc7ff3bfb2bb09e7d665a976e7e7ec1.png" height=7 />
</div>
<div class=frame>
    <span class="helper"></span>
    <img src="https://i-blog.csdnimg.cn/blog_migrate/5bc7ff3bfb2bb09e7d665a976e7e7ec1.png" height=5 />
</div>
<div class=frame>
    <span class="helper"></span>
    <img src="https://i-blog.csdnimg.cn/blog_migrate/5bc7ff3bfb2bb09e7d665a976e7e7ec1.png" height=3 />
</div>

.frame {
    height: 25px;      /* equals max image height */
    width: 160px;
    border: 1px solid red;
    white-space: nowrap;
    
    text-align: center; margin: 1em 0;
}

.helper {
    display: inline-block;
    height: 100%;
    vertical-align: middle;
}

img {
    background: #3A6F9A;
    vertical-align: middle;
    max-height: 25px;
    max-width: 160px;
}

 
 
 
 
 
 
 
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值