您的位置:首页 > 其它

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

2014-03-17 11:34 337 查看
工作中用到做笔记,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");}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: