0
0
Tailwindmarkup~10 mins

Sticky header and footer in Tailwind - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to make the header sticky at the top of the page.

Tailwind
<header class="bg-blue-600 text-white p-4 [1]">
  <h1 class="text-xl font-bold">My Website</h1>
</header>
Drag options to blanks, or click blank then click option'
Arelative
Bfixed bottom-0
Cabsolute top-0
Dsticky top-0
Attempts:
3 left
šŸ’” Hint
Common Mistakes
Using fixed positioning at the bottom instead of sticky at the top.
Using relative positioning which does not stick.
2fill in blank
medium

Complete the code to make the footer sticky at the bottom of the page.

Tailwind
<footer class="bg-gray-800 text-white p-4 [1]">
  <p>Ā© 2024 My Website</p>
</footer>
Drag options to blanks, or click blank then click option'
Asticky top-0
Bfixed top-0
Csticky bottom-0
Drelative
Attempts:
3 left
šŸ’” Hint
Common Mistakes
Using sticky top-0 which sticks to the top instead of bottom.
Using fixed top-0 which sticks to the top.
3fill in blank
hard

Fix the error in the main content area to avoid it being hidden behind the sticky header.

Tailwind
<main class="p-4 [1]">
  <p>Welcome to the main content!</p>
</main>
Drag options to blanks, or click blank then click option'
Amb-16
Bmt-16
Cpt-0
Dpb-0
Attempts:
3 left
šŸ’” Hint
Common Mistakes
Using margin-bottom instead of margin-top.
Using padding-top 0 which does not add space.
4fill in blank
hard

Fill both blanks to make the header and footer sticky and ensure the main content does not overlap them.

Tailwind
<header class="bg-blue-600 text-white p-4 [1]">
  <h1 class="text-xl font-bold">My Website</h1>
</header>

<main class="p-4 [2]">
  <p>Main content goes here.</p>
</main>

<footer class="bg-gray-800 text-white p-4 sticky bottom-0">
  <p>Ā© 2024 My Website</p>
</footer>
Drag options to blanks, or click blank then click option'
Asticky top-0
Bmt-16
Cmb-16
Dfixed top-0
Attempts:
3 left
šŸ’” Hint
Common Mistakes
Using fixed positioning for header which may cause overlap.
Adding margin-bottom instead of margin-top to main content.
5fill in blank
hard

Fill all three blanks to create a sticky header and footer with proper spacing in the main content.

Tailwind
<header class="bg-blue-600 text-white p-4 [1]">
  <h1 class="text-xl font-bold">My Website</h1>
</header>

<main class="p-4 [2] [3]">
  <p>Here is the main content area.</p>
</main>

<footer class="bg-gray-800 text-white p-4 sticky bottom-0">
  <p>Ā© 2024 My Website</p>
</footer>
Drag options to blanks, or click blank then click option'
Asticky top-0
Bmt-16
Cmb-16
Dfixed bottom-0
Attempts:
3 left
šŸ’” Hint
Common Mistakes
Forgetting margin-bottom on main content causing overlap with footer.
Using fixed positioning for header or footer incorrectly.