Skip to content

Instantly share code, notes, and snippets.

@fhefh2015
Forked from libo1106/gist:9777985
Last active March 8, 2016 08:19
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 fhefh2015/b6e55f338032fc9266dc to your computer and use it in GitHub Desktop.
Save fhefh2015/b6e55f338032fc9266dc 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