top and left correspond to the top-left corner of your box. Example for a 300x200 box: height: 200px; top:. In this recipe, you will see how to center one box inside another by using flexbox and grid, centering content both horizontally and vertically. Click "Play" in the code blocks below to edit the example in the MDN. There's no single "best" way to center a div. The right approach depends on your layout, content, and browser support needs. After building dozens of responsive websites and debugging centering issues in everything from legacy IE to modern mobile browsers, here are the 5 methods I actually use in. In this video we'll look at three of my favorite ways to center items, We'll use positioning, then we'll use flexbox, and lastly, we'll use my go-to CSS grid. The article "Five Ways to Center a Div With CSS" discusses various methods to center a child div within a parent div using CSS. The methods include using text-align, margin, relative positioning, absolute positioning. You use the Align panel (Window > Object & Layout > Align) to align or distribute objects horizontally or vertically along the selection, margins, page, or spread.