Зміст курсу
Tailwind CSS for Web Development
Tailwind CSS for Web Development
Responsive Design
Tailwind CSS makes it easy to create responsive designs by providing utility classes for breakpoints and media queries.
Breakpoints
Breakpoints in Tailwind CSS are defined at specific screen sizes, allowing you to apply different styles at different viewport widths.
Default Breakpoints
Breakpoint | Description |
sm | 640px |
md | 768px |
lg | 1024px |
xl | 1280px |
2xl | 1536px |
These breakpoints can be used as prefixes to apply styles conditionally based on the viewport width.
index
index
index
Explanation
bg-blue-500
: Sets the background color to a shade of blue by default;p-4
: Adds padding of 1rem (16px) on all sides;sm:bg-green-500
: Sets the background color to a shade of green on small screens and larger (min-width: 640px);md:bg-red-500
: Sets the background color to a shade of red on medium screens and larger (min-width: 768px);lg:bg-yellow-500
: Sets the background color to a shade of yellow on large screens and larger (min-width: 1024px);xl:bg-purple-500
: Sets the background color to a shade of purple on extra-large screens and larger (min-width: 1280px).
Applying Responsive Styles
You can apply responsive styles to any utility class in Tailwind CSS by prefixing it with a breakpoint.
index
index
index
Explanation
Padding:
p-4
: Adds padding of 1rem (16px) on all sides by default;sm:p-6
: Adds padding of 1.5rem (24px) on all sides for small screens and larger (min-width: 640px);md:p-8
: Adds padding of 2rem (32px) on all sides for medium screens and larger (min-width: 768px);lg:p-10
: Adds padding of 2.5rem (40px) on all sides for large screens and larger (min-width: 1024px);xl:p-12
: Adds padding of 3rem (48px) on all sides for extra-large screens and larger (min-width: 1280px).
Text Size:
sm:text-sm
: Sets the font size to small (0.875rem or 14px) for small screens and larger (min-width: 640px);md:text-base
: Sets the font size to base (1rem or 16px) for medium screens and larger (min-width: 768px);lg:text-lg
: Sets the font size to large (1.125rem or 18px) for large screens and larger (min-width: 1024px);xl:text-xl
: Sets the font size to extra-large (1.25rem or 20px) for extra-large screens and larger (min-width: 1280px).
Font Weight:
sm:font-light
: Applies light font weight for small screens and larger (min-width: 640px);md:font-normal
: Applies normal font weight for medium screens and larger (min-width: 768px);lg:font-semibold
: Applies semibold font weight for large screens and larger (min-width: 1024px);xl:font-bold
: Applies bold font weight for extra-large screens and larger (min-width: 1280px).
Note
Are you looking for specific information on responsiveness? Refer to the following link.
Дякуємо за ваш відгук!