Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Applying Basic Styling | Core Concepts and Basic Styling
Tailwind CSS for Web Development

book
Challenge: Applying Basic Styling

Task

Using the Tailwind CSS utilities for colors, borders, and shadows, create a styled card component with the following specifications:

  1. The outer container should have:

    • A white background color;

    • A medium shadow.

  2. The card should contain:

    • A heading (h2) with text-size of 2xl and text color of gray-900;

    • A paragraph (p) with a text color of gray-700.

  3. Inside the card, create a bordered box with:

    • A light blue background color (e.g., blue-50);

    • Blue border color;

    • Medium rounded corners;

    • Text color of blue-700.

  4. Add another box with:

    • A light green background color (e.g., green-100);

    • Green border color;

    • Rounded corners;

    • Small shadow;

    • Text color of green-700.

html

index.html

copy
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Challenge: Basic Styling - Task</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<div class="bg-_____ p-4 shadow-_____">
<h2 class="text-_____ text-_____-_____">Styled Card</h2>
<p class="_____-_____-_____">
This card is styled using Tailwind CSS utilities.
</p>
<div class="border border-_____-500 rounded-_____ p-4 bg-_____-_____">
<p class="_____-_____-_____">
This is a bordered box with a background color.
</p>
</div>
<div
class="mt-4 p-4 bg-_____-_____ border border-_____-_____ _____ shadow-_____"
>
<p class="_____-_____-_____">Another box with different styling.</p>
</div>
</div>
</body>
</html>
  1. Background Colors: Use bg-white, bg-blue-50, bg-green-100 for background colors;

  2. Text Colors: Use text-gray-900, text-gray-700, text-blue-700, text-green-700 for text colors;

  3. Border Colors: Use border-blue-500, border-green-500 for border colors;

  4. Border Radius: Use rounded-md, rounded for rounded corners;

  5. Shadows: Use shadow-md, shadow-sm for shadows;

  6. Text Size: Use text-2xl for the heading size.

html

index.html

copy
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Challenge: Basic Styling - Solution</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<div class="bg-white p-4 shadow-md">
<h2 class="text-2xl text-gray-900">Styled Card</h2>
<p class="text-gray-700">
This card is styled using Tailwind CSS utilities.
</p>
<div class="border border-blue-500 rounded-md p-4 bg-blue-50">
<p class="text-blue-700">
This is a bordered box with a background color.
</p>
</div>
<div
class="mt-4 p-4 bg-green-100 border border-green-500 rounded shadow-sm"
>
<p class="text-green-700">Another box with different styling.</p>
</div>
</div>
</body>
</html>

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 6

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

We use cookies to make your experience better!
some-alt