Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

css
html

How to align items to the center using Flexbox

Fahad Farid
svg viewer

Use the following steps to center align a button in a div container.

  1. Create a div container.
  2. Insert the button tag, image tag, or the text.
  3. In the CSS for the div, set justify-content to center.
  4. Set align-items to center.
  5. Set display to flex.

The button and all the contents within the div should now be center aligned.

Below is a working code example that can help you better understand the concept:

RELATED TAGS

css
html

CONTRIBUTOR

Fahad Farid
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring