chadlly2003
Just a tip anytime you want to center something that is in a flex box the width must be 100%
.parent-container { display: flex; justify-content: center; /* Centers horizontally (on the main axis) / align-items: center; / Centers vertically (on the cross axis) */ }
.parent-container {
display: flex;
}
.child-item {
margin: auto; /* Automatically sucks up all remaining space on all sides, perfectly centering the item */
}
Why you might have thought 100% width was required
If your flex container doesn't have an explicit size or isn't a block-level element spanning the width of the screen, it will default to shrinking tightly around its contents. In that scenario, the child item is centered within the flexbox, but the flexbox itself is small and off to the left side of the page. [1]
If you want the item centered in the middle of the entire screen, the parent container needs space to work with. You can give it that space using width, height, or viewports: [1, 2]
Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com