Skip to content

Instantly share code, notes, and snippets.

@damijanc
Forked from iamstarkov/dabblet.css
Last active August 29, 2015 14:21
Show Gist options
  • Save damijanc/34c084c835ef105a6de6 to your computer and use it in GitHub Desktop.
Save damijanc/34c084c835ef105a6de6 to your computer and use it in GitHub Desktop.
centering with absolute position
/**
* centering with absolute position
*/
div.header {
width: 100%;
background-color:green;
height: 30px;
position:relative;
}
div.container {
position:relative;
width: 100%;
height: 400px;
}
div.body {
width: 100px;
height: 100px;
background-color: red;
position: absolute;
top:0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
div.footer {
width: 100%;
background-color:yellow;
height: 30px;
position:relative;
}
div.impressum {
width: 20px;
background-color:blue;
height: 30px;
position:relative;
margin-left: 10%;
}
<div class="header"></div><div class="container"><div class="body"></div></div><div class="footer"><div class="impressum"></div></div>
{"view":"split-vertical","fontsize":"100","seethrough":"","prefixfree":"1","page":"result"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment