Skip to content

Instantly share code, notes, and snippets.

@kejun
Forked from anonymous/dabblet.css
Created May 12, 2013 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kejun/5563872 to your computer and use it in GitHub Desktop.
Save kejun/5563872 to your computer and use it in GitHub Desktop.
方法1:
html,body { height:100%; }
.list { padding:10px; border:3px solid #ccc; }
/*
方法1:
html,body { height:100%; }
body {
text-align:center;
}
.list {
display: inline-block;
vertical-align: middle;
text-align: left;
}
body:before {
content: '';
display: inline-block;
height:100%;
vertical-align: middle;
}
*/
/*
方法2:
html {
display: table;
width: 100%;
height: 100%;
}
body {
display: table-cell;
text-align: center;
vertical-align: middle;
}
.list {
display: inline-block;
text-align:left;
}
*/
/*
方法3:
body {
display: flex;
justify-content: center;
align-items: center;
}
*/
/*
方法4:
.list {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
}
*/
<div class="list">
<img src="http://dummyimage.com/200">
<p>hi, box
<p>hi, box
<p>hi, box
<p>hi, box
</div>
// alert('Hello world!');
{"view":"separate","fontsize":"100","seethrough":"","prefixfree":"1","page":"css"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment