兼容IE6 7 8 chrome firefox图片水平垂直居中

工作中用到做笔记,table-layout: fixed;解决IE8下左右边距变大,Google到的解决办法

http://bytes.com/topic/html-css/answers/870359-ie8-display-table-cell-max-width-bug

<div class="item"><p><img src="http://www.kddev.com/upload/member/22/22_4a37c7c814fbe57010db5b619a92d414.jpg_240x240.jpg"></p></div>


/*图片列表 兼容IE6水平垂直居中*/
/*For Firefox Chrome*/
.photo-list .item{float: left;cursor: pointer;border:1px #eee solid;width:100px;height:100px;table-layout: fixed;overflow:hidden;text-align:center;display:table;float:left;margin-left:20px; margin-top: 20px;position:relative;}
.photo-list .item p{display:table-cell;vertical-align:middle;width:100px;height:100px;}
.photo-list .item img{margin:0 auto;max-width:100px;max-height:100px;}
/*For IE7*/
*+html .photo-list p{position:absolute;top:50%;width:auto;text-align:center;height:auto;}
*+html .photo-list p img{position:relative;top:-50%;left:-50%;}
/*For IE6*/
*html .photo-list p{position:absolute;top:51%;width:100%;text-align:center;height:auto;display:block;}
*html .photo-list p img{position:relative;top:-50%;left:-50%;width:expression(this.width>100?"100px":"auto");height:expression(this.height>100?"100px":"auto");}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值