Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

One way to horizontally center a group of items while also aligning them to the left is to use a combination of CSS properties. You can set the parent container to have a display of flex with justify-content set to center, and then set the child items to have a text-align of left. This will center the items horizontally within the container and align the contents to the left. Here is an example:

HTML:

<div class="container">
  <div class="item">Item 1</div>
  <div class="item">Item 2</div>
  <div class="item">Item 3</div>
</div>

CSS:

.container {
  display: flex;
  justify-content: center;
}

.item {
  text-align: left;
}

This will center the items horizontally within the container, while also aligning the text of each item to the left.