To center 6 divs in one parent div, you can use CSS flexbox. Here’s an example:
HTML:
cssCopy code<div class="parent">
<div>Div 1</div>
<div>Div 2</div>
<div>Div 3</div>
<div>Div 4</div>
<div>Div 5</div>
<div>Div 6</div>
</div>
CSS:
cssCopy code.parent {
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
}
.parent div {
width: 100px;
height: 100px;
background-color: #ccc;
margin: 10px;
}
In the above example, we first create a parent div with six child divs. We then set the parent div’s display property to “flex” and use the “justify-content” and “align-items” properties to center the child divs horizontally and vertically within the parent div.
We also use the “flex-wrap” property to allow the child divs to wrap to the next line if they exceed the width of the parent div.
Finally, we set the width, height, and background color of the child divs, and add some margin to create some space between them.