Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Responsive Design | Responsiveness and Customization
Tailwind CSS for Web Development
course content

Contenido del Curso

Tailwind CSS for Web Development

Tailwind CSS for Web Development

1. Introduction and Setup
2. Core Concepts and Basic Styling
3. Building Basic Components
4. Layout Basics
5. Responsiveness and Customization

bookResponsive 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

BreakpointDescription
sm640px
md768px
lg1024px
xl1280px
2xl1536px

These breakpoints can be used as prefixes to apply styles conditionally based on the viewport width.

html

index

css

index

js

index

copy

Explanation

  1. bg-blue-500: Sets the background color to a shade of blue by default;
  2. p-4: Adds padding of 1rem (16px) on all sides;
  3. sm:bg-green-500: Sets the background color to a shade of green on small screens and larger (min-width: 640px);
  4. md:bg-red-500: Sets the background color to a shade of red on medium screens and larger (min-width: 768px);
  5. lg:bg-yellow-500: Sets the background color to a shade of yellow on large screens and larger (min-width: 1024px);
  6. 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.

html

index

css

index

js

index

copy

Explanation

Padding:

  1. p-4: Adds padding of 1rem (16px) on all sides by default;
  2. sm:p-6: Adds padding of 1.5rem (24px) on all sides for small screens and larger (min-width: 640px);
  3. md:p-8: Adds padding of 2rem (32px) on all sides for medium screens and larger (min-width: 768px);
  4. lg:p-10: Adds padding of 2.5rem (40px) on all sides for large screens and larger (min-width: 1024px);
  5. xl:p-12: Adds padding of 3rem (48px) on all sides for extra-large screens and larger (min-width: 1280px).

Text Size:

  1. sm:text-sm: Sets the font size to small (0.875rem or 14px) for small screens and larger (min-width: 640px);
  2. md:text-base: Sets the font size to base (1rem or 16px) for medium screens and larger (min-width: 768px);
  3. lg:text-lg: Sets the font size to large (1.125rem or 18px) for large screens and larger (min-width: 1024px);
  4. 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:

  1. sm:font-light: Applies light font weight for small screens and larger (min-width: 640px);
  2. md:font-normal: Applies normal font weight for medium screens and larger (min-width: 768px);
  3. lg:font-semibold: Applies semibold font weight for large screens and larger (min-width: 1024px);
  4. 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.

1. How do you apply a background color at the `md` breakpoint?
2. Which utility class changes the padding at the `sm` breakpoint?
How do you apply a background color at the `md` breakpoint?

How do you apply a background color at the md breakpoint?

Selecciona la respuesta correcta

Which utility class changes the padding at the `sm` breakpoint?

Which utility class changes the padding at the sm breakpoint?

Selecciona la respuesta correcta

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 5. Capítulo 1
We're sorry to hear that something went wrong. What happened?
some-alt