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

来源:互联网 发布:javascript 权威指南 编辑:程序博客网 时间:2024/05/14 14:30

工作中用到做笔记,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");}


0 0
原创粉丝点击