-
-
Save kejun/5563872 to your computer and use it in GitHub Desktop.
方法1:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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%); | |
} | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="list"> | |
<img src="http://dummyimage.com/200"> | |
<p>hi, box | |
<p>hi, box | |
<p>hi, box | |
<p>hi, box | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// alert('Hello world!'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"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