关注前端开发
关注用户体验

图片在div内垂直水平居中

<style type=”text/css”>

.img_pro{width:120px;height:120px;overflow:hidden;position:relative;display:table-cell;text-align:center;vertical-align:middle; border:#ccc 1px solid;}

.img_pro a{position:static;+position:absolute;top:50%}

.img_pro a img{position:static;+position:relative;top:-50%;left:-50%;max-width:120px;_width:expression(this.width>120?”120px”:”atuo”);max-height:120px; _height:expression(this.height>120?”120px”:atuo);}

</style>

<div src=”http://www.baidu.com/img/baidu_logo.gif” /></a></div>

赞(0)
未经允许不得转载:大前端 » 图片在div内垂直水平居中
分享到: 更多 (0)

评论 2

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #2

    Good Post, I am a big believer in leaving comments on sites to help the blog writers know that they’ve added something advantageous to the world wide web!

    cat blog3周前 (05-09)回复
  2. #1

    Great tips to follow. Being professional and showing them there’s more to come I think are the most important. You need to give them a great article, that makes them want to come back. And then make sure you don’t disappoint.

    my singing monsters2个月前 (03-28)回复

themebetter 国内更好的WordPress主题服务商

立即前往