Skip to content

Instantly share code, notes, and snippets.

@QETHAN
Created June 24, 2014 10:52
Show Gist options
  • Save QETHAN/c2a3061ff5bc23d36361 to your computer and use it in GitHub Desktop.
Save QETHAN/c2a3061ff5bc23d36361 to your computer and use it in GitHub Desktop.
垂直居中,容器高度固定,内容高度不定
* {
margin: 0;
padding: 0;
}
.cont {
background-color: #ccc;
font-size: 24px;
height: 150px;
text-align: center;
overflow: hidden;
width: 280px;
}
.cont .inner,
.cont .v {
display: inline-block;
zoom: 1;*display: inline; /* 用于触发支持IE67 inline-block */
}
.cont .inner {
line-height: 1.8;
padding: 0 4px 0 5px;
vertical-align: middle;
width: 262px;
}
.cont .v {
line-height: 150px;
text-indent:-9999px;
width: 1px;
}
<div class="cont">
<div class="inner">比较满意比较满意比较满意</div><div class="v">cssHack</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment