<section>
<div id="object"></div>
<div>Hello World!</div>
</section>
body {
font-family: Helvetica, Arial, sans-serif;
font-size: 18px;
}
section {
height: 100vh;
overflow: hidden;
display: flex;
flex-direction: column;
/* Align all my children horizontally in the centre. */
justify-content: center;
/* Let's also vertically align in the centre all items added to the flex--not just one. */
align-items: center;
}
#object {
height: 100px;
width: 100px;
background: red;
align-self: center; /* Just vertically aligns me ;-) */
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.