Skip to content

Instantly share code, notes, and snippets.

@renhao
Created December 12, 2012 10:58
Show Gist options
  • Save renhao/4266920 to your computer and use it in GitHub Desktop.
Save renhao/4266920 to your computer and use it in GitHub Desktop.
实现一个不定宽高的层,在窗口中水平垂直居中——by克军
.mod {
position: absolute;
width: 300px;
background: #eee;
border: 1px solid #eee;
padding: 0 50px;
-webkit-box-shadow: 0 0 4px 0 rgba(0,0,0,0.2);
-moz-box-shadow: 0 0 4px 0 rgba(0,0,0,0.2);
box-shadow: 0 0 4px 0 rgba(0,0,0,0.2);
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
<div class="mod">
<p>武松跟张青夫妻,真是一见如故。十字坡人肉铺里,把赤膊的二娘压在地上,恰张青赶到,喝住了。刚把孙二娘从地上放起来,他马上叫起嫂嫂,“却才冲撞,嫂嫂休怪”。...</p>
<p>才知道】睡前洗热水澡容易失眠(因为会推迟褪黑素的分泌,脑垂体上的松果体分泌褪黑素人就睡觉...大概如此)</p>
</div>
// alert('Hello world!');
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"html"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment