What is the best way to position a horizontally centered element at the top, a horizontally centered at the bottom and an element at the center of the screen?
You need to set the height of the html and body to 100%, then use flexbox with flex-direction: column; to make it operate vertically, and justify-content: space-between; to do the spacing.
The display: grid can also be used to attain the desire. Grid-Template-Rows and Grid-Template-Columns can be used to set the appropriate size for each row and column, respectively. In this case, the fractional unit Fr stands for one part of the available space (1fr). For more information on fr, visit this page.
3
Answers
You need to set the height of the html and body to 100%, then use flexbox with
flex-direction: column;
to make it operate vertically, andjustify-content: space-between;
to do the spacing.To horizontally align center a block element (like paragraph inside div) as well as Text, use margin: auto;
The display: grid can also be used to attain the desire. Grid-Template-Rows and Grid-Template-Columns can be used to set the appropriate size for each row and column, respectively. In this case, the fractional unit Fr stands for one part of the available space (1fr). For more information on fr, visit this page.