Skip to content

Instantly share code, notes, and snippets.

@ch-gilbert
Created September 16, 2013 05:40
Show Gist options
  • Save ch-gilbert/6577034 to your computer and use it in GitHub Desktop.
Save ch-gilbert/6577034 to your computer and use it in GitHub Desktop.
纯CSS控制不固定宽高图片div内水平垂直均居中 (http://sandbox.runjs.cn/show/c9zvoil2)
<style>
.img-outSide{
width: 500px;
height: 750px;
border: 1px solid #CDCDCD;
text-align: center;
}
.img-inSide,.img-con{
display: inline-block;
vertical-align: middle;
}
.img-inSide{
height: 100%;
}
</style>
<div class="img-outSide">
<a href="#" class="img-con">
<img style="float: left;" src="http://sandbox.runjs.cn/uploads/rs/234/k0xxr73w/1.jpg" />
</a>
<b class="img-inSide"></b>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment