Skip to content

Instantly share code, notes, and snippets.

@aaitken
Forked from ajaswa/centered.css
Created October 24, 2012 18:21
Show Gist options
  • Select an option

  • Save aaitken/3947851 to your computer and use it in GitHub Desktop.

Select an option

Save aaitken/3947851 to your computer and use it in GitHub Desktop.
vertical align content
<!doctype html>
<html>
<head>
<link href="lightbox.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="lightbox">
<div class="overlay"></div>
<div class="wrapper">
<div class="inner">
<div class="content">
content sdlkfjsdlf lsdkfj sdlfks sldfkj <br>sdlfkj sdf lksdjf sdlfkjsd flsdkfj s<br>
content sdlkfjsdlf lsdkfj sdlfks sldfkj <br>sdlfkj sdf lksdjf sdlfkjsd flsdkfj s
</div>
</div>
</div>
</div>
</body>
</html>
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.lightbox {
position: fixed;
width: 100%;
height: 100%;
text-align: center;
}
.lightbox .overlay {
height: 100%;
width: 100%;
position: absolute;
top: 0;
left: 0;
z-index: 10;
background-color: rgba(0,0,0,0.5);
}
.lightbox:before {
content: ' ';
height: 100%;
background-color: blue;
}
.lightbox:before,
.lightbox .wrapper {
display: inline-block;
text-align: left;
vertical-align: middle;
position: relative;
z-index: 20;
}
.lightbox .wrapper {
background-color: red;
}
.lightbox .inner {
max-height: 500px;
max-width: 500px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment