<!-- our html has a container which contains a div we wish to center-->
<div class="container center">
<div class="inner">
</div>
</div>
html,
body {
height: 100%;
}
.container {
background: black;
width: 100%;
height: 100%;
font-size: 2rem;
}
.inner {
background: turquoise;
width: 50px;
height: 50px;
border-radius: 50%;
}
/* This is the main CSS that centers the div */
.inner{
margin: auto;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.