From the course: Interactive Animations with CSS and JavaScript

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Center element CSS flexbox

Center element CSS flexbox

From the course: Interactive Animations with CSS and JavaScript

Start my 1-month free trial

Center element CSS flexbox

- [Instructor] We're making progress and then we have a distinct slide that is centered inside the presentation. Now I want to center the presentation area on my page, which for our purposes is gonna be within the HP content element. So we want this to be centered both horizontally and vertically in the parent. There are numerous strategies for this and the one we used in the last video was margins. For this one, I'd like to introduce a new concept called flexbox. Flexbox is a CSS style that allows you to control how children are displayed within their parents, and it's very handy for doing layouts like this where you want to simultaneously horizontally and vertically center things. If you've ever dug into that, it can be involved. So we're gonna go to a site that I actually built to play with so you can see what various flex properties will do whenever you use them in the wild. For our purposes, we're gonna focus on the ones that are needed to center something. So as you can see we…

Contents