div center of page code example
Example 1: css align center
//HTML
<div class="parent">
<span>Hello World</span>
</div>
//CSS
.parent {
display: flex;
justify-content: center;
align-items: center;
}
Example 2: how to put container in center of page
#container
{
width: 400px;
margin-left: auto;
margin-right: auto;
}
Example 3: css center div
<!--
Simple CSS CENTER DIV Example
* See Fiddle in link for PoC *
-->
<div class="parent">
<div class="child">
<p>
Eh Up Me Duck!
</p>
</div>
</div>
<style>
.parent {
border: 1px solid black;
padding: 2px;
}
.child {
border: 1px solid red;
width: 50%;
margin-left: auto;
margin-right: auto;
}
p {
text-align: center;
}
</style>
Example 4: show element at center of page
.centered {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}Remember this forever
Example 5: how to put container in center of page
div.InSkinAlignCenter {
margin: 0 auto;
}