Skip to content

Instantly share code, notes, and snippets.

@dandean
Created April 23, 2010 16:58
Show Gist options
  • Select an option

  • Save dandean/376796 to your computer and use it in GitHub Desktop.

Select an option

Save dandean/376796 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Pure CSS Vertical Centering via CSS3 Flexible Box Model</title>
<style type="text/css" media="screen">
html {
height: 100%;
}
body {
background: #333;
margin: 0;
padding: 0;
height: 100%;
width: 100%;
/* WEBKIT */
display: -webkit-box;
-webkit-box-align: center;
-webkit-box-orient: horizontal;
-webkit-box-pack: center;
/* FIREFOX */
display: -moz-box;
-moz-box-align: center;
-moz-box-orient: horizontal;
-moz-box-pack: center;
/* FUTURE: ALL */
display: box;
box-align: center;
box-orient: horizontal;
box-pack: center;
}
body > div {
padding: 20px;
}
div#box1 {
background: cyan;
-moz-border-radius: 5px 0 0 5px;
border-radius: 5px 0 0 5px;
}
div#box2 {
background: magenta;
}
div#box3 {
background: yellow;
-moz-border-radius: 0 5px 5px 0;
border-radius: 0 5px 5px 0;
}
</style>
</head>
<body>
<div id="box1">1</div>
<div id="box2">2</div>
<div id="box3">3</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment