Middle
How do you work with responsive design? What approaches do you use?
sobes.tech AI
Answer from AI
For responsive layout, I usually use a combination of the following approaches:
- Media Queries (CSS Media Queries): allow changing styles depending on screen width, device orientation, and other characteristics.
- Flexible units of measurement: such as %, vw, vh, rem, which allow elements to adapt to the screen size.
- Flexbox and CSS Grid: for building flexible and responsive layouts.
- Mobile-first approach: I first write styles for mobile devices, then expand for larger screens.
- Using ready-made CSS frameworks: such as Bootstrap or Tailwind, which have built-in support for responsiveness.
Example of a media query:
.container {
width: 100%;
}
@media (min-width: 768px) {
.container {
width: 750px;
}
}
@media (min-width: 1200px) {
.container {
width: 1170px;
}
}
This approach allows adjusting the container width for different screen sizes.