This example demonstrates the "Gotcha": responsive prefixes apply to that screen size *and larger*, unless overridden. We want to show a yellow box *only* on medium (`md`, 768px to 1023px) screens.
If we only use
hidden md:block
, the element will be hidden on small screens, but then visible on medium screens AND ALSO on large screens because
md:
applies to medium and up.
(Gotcha) Visible on MD and UP (768px+):
hidden md:block
This box demonstrates the gotcha. It appears on medium screens AND stays visible on large screens.
To show an element *only* on medium screens, we need to hide it by default, show it on medium, and then hide it again on large screens.
(Correct) Visible ONLY on MD screens (768px - 1023px):
hidden md:block lg:hidden
This box is hidden on small screens, visible on medium screens, and hidden again on large screens.