how to align text in center of div code example
Example 1: center a div in css
.container {
display: flex;
justify-content: center;
align-items: center;
}
Example 2: css center text in div
parent-element {text-align:center;}
parent-element {position: relative;}
element-to-be-centered {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
Example 3: css center
// example 1
div { display: grid; place-items: center; }
// example 3
div{ display:flex; align-items:center; }
// example 3
div { width: 100%; margin: 0 auto; }
Example 4: how to center a div
margin:auto
Example 5: how to center a text element
It's okay bro use text-align: center; or justify-content with flexbox it's a lifesaver