Last active
May 23, 2017 02:20
-
-
Save ruyaoyao/5db9790d0fc7fc299aae0ef3dd903004 to your computer and use it in GitHub Desktop.
CSS 垂直置中解法, Making element to align vertically. JS Bin// source http://jsbin.com/dunutiwone
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
.ot { | |
width: 400px; | |
height: 400px; | |
border: 1px solid #FF6600; | |
text-align: center; | |
margin: 0 auto; | |
} | |
.ot:before { | |
content: ''; | |
display: inline-block; | |
vertical-align: middle ; | |
height: 100%; | |
} | |
.wrapper { | |
display: inline-block; | |
vertical-align: middle; | |
width: 200px; | |
height: 200px; | |
background: #ccc; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="ot"> | |
<div class="wrapper"></div> | |
</div> | |
<script id="jsbin-source-css" type="text/css">.ot { | |
width: 400px; | |
height: 400px; | |
border: 1px solid #FF6600; | |
text-align: center; | |
margin: 0 auto; | |
} | |
.ot:before { | |
content: ''; | |
display: inline-block; | |
vertical-align: middle ; | |
height: 100%; | |
} | |
.wrapper { | |
display: inline-block; | |
vertical-align: middle; | |
width: 200px; | |
height: 200px; | |
background: #ccc; | |
} | |
</script> | |
</body> | |
</html> |
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
.ot { | |
width: 400px; | |
height: 400px; | |
border: 1px solid #FF6600; | |
text-align: center; | |
margin: 0 auto; | |
} | |
.ot:before { | |
content: ''; | |
display: inline-block; | |
vertical-align: middle ; | |
height: 100%; | |
} | |
.wrapper { | |
display: inline-block; | |
vertical-align: middle; | |
width: 200px; | |
height: 200px; | |
background: #ccc; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment