Evan Genest's Learning Log

These are notes to myself. If you discover them and find them useful I would love to hear from you. Most of these are related to travel I did, books I read, or tech notes for Matomo and the LAMP stack.


Browse my topics here

HTML and CSS snippets

javascript

Centering something vertically and horizontally

Without Flexbox or Grid.

<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

.container {
position: relative;
height: 400px;
border: 2px solid #006100;
}

.centered-element {
margin: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}


</style>
<div class="container">
<div class="centered-element">
<p>As a sentence I consider myself doubly centered</p>
</div>
</div>