bottom

Term side of the Card.
Topic: Positioning
Unit title: bottom
Categories: Property
Explanation side of the Card

Explanation: The property that sets the distance between the bottom edge of an element and the bottom edge of its containing block. With 'absolute' or 'fixed' `position` it places the element in its nearest positioned ancestor or the viewport, while with 'relative' it shifts it from its normal place.

Browser compatibility:
  • The chrome browser supports this feature starting from version 1.
  • The edge browser supports this feature starting from version 12.
  • The firefox browser supports this feature starting from version 1.
  • The safari browser supports this feature starting from version 1.
Availability: 

Example

Wrongcss
.toast {
  position: fixed;
  bottom: 16px;
}
Rightcss
.toast {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

Adding the safe area inset keeps the toast above the home indicator on phones with no physical buttons.

Common mistakes

  • A fixed bottom bar hides behind the phone's home indicator.
  • The last item on the page is covered by a fixed footer.

Key points

  • Fixed bottom bars add env(safe-area-inset-bottom) so they clear the home indicator.
  • Elements using bottom have a position other than 'static'.
  • Page content gets enough bottom padding so a fixed bar doesn't cover it.

Interview questions

Why is bottom: 0 not working?

The element needs a position other than 'static', and for 'absolute' its containing block must be tall enough.

What is the difference between bottom and margin-bottom?

bottom moves a positioned element without affecting others, while margin-bottom changes spacing in normal flow.

What is the logical version of bottom?

inset-block-end, which follows the writing mode.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy