Created
May 23, 2017 02:20
-
-
Save ruyaoyao/fac65ed8492ef2e3ae42e3c95005175a to your computer and use it in GitHub Desktop.
多行文本未知高度垂直居中-by一丝 // source http://jsbin.com/xowiyuw
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>多行文本未知高度垂直居中-by一丝</title> | |
<style id="jsbin-css"> | |
*{margin:0;padding:0;} | |
.box{ | |
height:200px; | |
width:300px; | |
background:pink; | |
margin:30px auto; | |
font-size:0; | |
} | |
.box:before{ | |
content: '我是那个备胎元素'; | |
display: inline-block; | |
vertical-align: middle; | |
width: 0; | |
height: 100%; | |
} | |
.text{ | |
display: inline-block; | |
font-size:16px; | |
vertical-align: middle;/* 保证文字垂直居中 */ | |
} | |
</style> | |
</head> | |
<body> | |
<body> | |
<div class="box"> | |
<p class="text"> | |
多行文本未知高度垂直居中-by 一丝多行文本未知高度垂直居中-by 一丝多行文本未知高度垂直居中-by 一丝 | |
</p> | |
</div> | |
<script id="jsbin-source-css" type="text/css">*{margin:0;padding:0;} | |
.box{ | |
height:200px; | |
width:300px; | |
background:pink; | |
margin:30px auto; | |
font-size:0; | |
} | |
.box:before{ | |
content: '我是那个备胎元素'; | |
display: inline-block; | |
vertical-align: middle; | |
width: 0; | |
height: 100%; | |
} | |
.text{ | |
display: inline-block; | |
font-size:16px; | |
vertical-align: middle;/* 保证文字垂直居中 */ | |
}</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
*{margin:0;padding:0;} | |
.box{ | |
height:200px; | |
width:300px; | |
background:pink; | |
margin:30px auto; | |
font-size:0; | |
} | |
.box:before{ | |
content: '我是那个备胎元素'; | |
display: inline-block; | |
vertical-align: middle; | |
width: 0; | |
height: 100%; | |
} | |
.text{ | |
display: inline-block; | |
font-size:16px; | |
vertical-align: middle;/* 保证文字垂直居中 */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment