center item in css code example
Example 1: center a div in css
.container {
display: flex;
justify-content: center;
align-items: center;
}
Example 2: css align center
//HTML
<div class="parent">
<span>Hello World</span>
</div>
//CSS
.parent {
display: flex;
justify-content: center;
align-items: center;
}
Example 3: centering css elements
// add to the parent element
.parent {
display: grid;
place-items: center;
}
Example 4: how to make things center using css
// add to the parent element
.parent{
height:100vh;
display:flex;
justify-content: center;
align-items: center;
}
Example 5: center css elements
body{
display: grid;
place-items: center;
}
Example 6: align center css
margin: auto;