1<style>
2.parent { position: relative; }
3.centered-element {
4 position: absolute;
5 left: 50%;
6 transform: translateX(-50%);
7}
8
9</style>
10
11<div class="parent">
12 <div class="centered-element">I'm Centered!</div>
13</div>
1position: absolute;
2top: 50%;
3left: 50%;
4transform: translate(-50%, -50%);
5