Skip to content

Instantly share code, notes, and snippets.

@janily
Forked from libo1106/gist:9777985
Created September 22, 2016 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janily/fac045b5725f579e5f05294a282ca5be to your computer and use it in GitHub Desktop.
Save janily/fac045b5725f579e5f05294a282ca5be to your computer and use it in GitHub Desktop.
flex未知高度垂直居中写法
<!DOCTYPE html>
<html lang="zh-CN" class="fullscreen">
<head>
<title>flex未知高度垂直居中写法</title>
<style>
html,body{
width: 100%;
height: 100%;
overflow: hidden;
}
.wrap{
/* ie10 */
display: -ms-flexbox;
-ms-flex-align:center;
/* android */
display: -webkit-box;
-webkit-box-orient: horizontal;
-webkit-box-pack: center;
-webkit-box-align: center;
display: box;
box-orient: horizontal;
box-pack: center;
box-align: center;
/* chrome、 iOS */
display: -webkit-flex;
display: flex;
-webkit-align-items: center;
align-items: center;
-webkit-justify-content: center;
justify-content: center;
width: 100%;
height: 100%;
}
.content{
width: 100%;
background-color: #f90;
height: 100px;
}
</style>
</head>
<body>
<div class="wrap">
<div class="content">
content
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment