Hello there!
Let's learn something today.
YOU'RE BUILDING
Pharmasift Part I
ROADMAP
Frontend
DIFFICULTY LEVEL
Beginner
4. Responsive with Tailwind
We'll update the existing CSS-based responsiveness to utilize Tailwind's responsive utility classes, allowing elements to adapt to different screen sizes.
Existing CSS for Responsiveness:
Consider the following CSS styles for responsiveness:
/* Existing CSS styles for responsiveness */
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.heading {
font-size: 24px;
}
@media (max-width: 768px) {
.container {
padding: 10px;
}
.heading {
font-size: 20px;
}
}
Transition to Tailwind's Responsive Classes:
Now, let's transition the existing CSS-based responsiveness to Tailwind's responsive utility classes:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Responsive with Tailwind</title>
<!-- Add Tailwind CSS via CDN -->
<link
href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css"
rel="stylesheet"
/>
</head>
<body>
<div class="max-w-screen-lg mx-auto p-4">
<p class="text-3xl lg:text-5xl">Hello, Tailwind!</p>
</div>
</body>
</html>
This looks so amazing now. Just with a few words we can replace everything written in CSS.
You just completed Tailwind. Now it’s time to replace CSS with Tailwind.