CSS • Chapter 55 • Foundations to Production
Responsive Navigation and Sidebars
Every topic includes a CSS/HTML coding example, ten focused teaching examples, code explanation, expected result, practice, and responsive/translated-layout checks.
55.1 Mobile Navigation
Mobile Navigation is part of the CSS system covered in Chapter 55. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size. The goal is to connect the syntax to the browser's layout and cascade decisions rather than memorize a property name.
For Mobile Navigation in Chapter 55, inspect the matched selector, computed value, containing block or formatting context, intrinsic size, and any min/max constraints. When translation is enabled, also inspect whether longer text or RTL direction changes the available inline space.
Start with one small example for Mobile Navigation, resize the viewport, increase text size, translate the label, and add a competing rule. This shows whether the technique remains predictable under real content rather than only in a fixed desktop mockup. This explanation is specific to Chapter 55, topic 1.
Concept in plain language
Mobile Navigation is part of the CSS system covered in Chapter 55. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size.
10 teaching examples
Example 1: Smallest useful case
Build a minimal notification for Mobile Navigation. Keep only the declarations needed to see the behavior clearly, then inspect the computed styles. Chapter 55, topic 1, example 1.
Example 2: Change one value
Change one important CSS value in the language selector example for Mobile Navigation. Predict the visual difference before reloading the page. Chapter 55, topic 1, example 2.
Example 3: Narrow-screen test
Test Mobile Navigation in the course card at 320px, 375px, and tablet width. Watch for min-content sizing, unwrapped text, and elements that refuse to shrink. Chapter 55, topic 1, example 3.
Example 4: Translated-text test
Translate the navigation bar into a language with longer labels while using Mobile Navigation. Confirm buttons, headings, and navigation wrap without widening the page. Chapter 55, topic 1, example 4.
Example 5: Arabic/Persian test
Switch the article to Arabic or Persian. Verify logical spacing, start/end alignment, sidebar direction, and LTR code islands. Chapter 55, topic 1, example 5.
Example 6: Accessibility test
Check Mobile Navigation in the profile panel with keyboard focus, zoom, reduced motion, forced colors, and high text scaling where relevant. Chapter 55, topic 1, example 6.
Example 7: Cascade test
Add a competing rule to the search form and determine why the declaration for Mobile Navigation wins or loses using the browser's Styles and Computed panels. Chapter 55, topic 1, example 7.
Example 8: Content-stress test
Fill the dashboard with very long words, URLs, translated text, images, and nested controls. Adjust Mobile Navigation without hiding meaningful content. Chapter 55, topic 1, example 8.
Example 9: Refactoring test
Rewrite the photo gallery so Mobile Navigation uses reusable tokens, logical properties, or a component class while preserving the same behavior. Chapter 55, topic 1, example 9.
Example 10: Production review
Review Mobile Navigation in the pricing table for browser support, fallback behavior, RTL, small screens, print, motion preferences, and maintainability. Chapter 55, topic 1, example 10.
CSS/HTML coding example
<!-- HTML -->
<button class="menu-button">Menu</button><nav class="nav">Links</nav>
<style>
@media (max-width:48rem){.nav{display:none}.menu-button{display:block}}
</style>Step-by-step code explanation
- Identify the selector and declaration that demonstrate Mobile Navigation.
- Read the HTML structure first so you know which box or relationship the CSS is styling.
- A media query can switch from full navigation to a compact control.
- Resize the viewport and test long translated content. Confirm that flex/grid items use min-width:0 where needed and that only code or genuinely wide content scrolls locally.
- Switch to Arabic or Persian and verify logical start/end spacing, text alignment, sidebar direction, and LTR isolation for code.
Expected result: The browser visibly demonstrates Mobile Navigation without requiring the page to exceed the viewport width. If the example contains wide code, only the code block scrolls horizontally. This expected result belongs to Chapter 55, topic 1.
Practice exercise
Build a fresh example for Mobile Navigation from Chapter 55. Change one value, inspect the computed styles, test at 320px and tablet width, translate the visible text, switch the page to RTL, and explain why the final declaration or layout behavior occurs.
55.2 Off-Canvas Sidebar
Off-Canvas Sidebar is part of the CSS system covered in Chapter 55. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size. The goal is to connect the syntax to the browser's layout and cascade decisions rather than memorize a property name.
For Off-Canvas Sidebar in Chapter 55, inspect the matched selector, computed value, containing block or formatting context, intrinsic size, and any min/max constraints. When translation is enabled, also inspect whether longer text or RTL direction changes the available inline space.
Start with one small example for Off-Canvas Sidebar, resize the viewport, increase text size, translate the label, and add a competing rule. This shows whether the technique remains predictable under real content rather than only in a fixed desktop mockup. This explanation is specific to Chapter 55, topic 2.
Concept in plain language
Off-Canvas Sidebar is part of the CSS system covered in Chapter 55. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size.
10 teaching examples
Example 1: Smallest useful case
Build a minimal navigation bar for Off-Canvas Sidebar. Keep only the declarations needed to see the behavior clearly, then inspect the computed styles. Chapter 55, topic 2, example 1.
Example 2: Change one value
Change one important CSS value in the article example for Off-Canvas Sidebar. Predict the visual difference before reloading the page. Chapter 55, topic 2, example 2.
Example 3: Narrow-screen test
Test Off-Canvas Sidebar in the profile panel at 320px, 375px, and tablet width. Watch for min-content sizing, unwrapped text, and elements that refuse to shrink. Chapter 55, topic 2, example 3.
Example 4: Translated-text test
Translate the search form into a language with longer labels while using Off-Canvas Sidebar. Confirm buttons, headings, and navigation wrap without widening the page. Chapter 55, topic 2, example 4.
Example 5: Arabic/Persian test
Switch the dashboard to Arabic or Persian. Verify logical spacing, start/end alignment, sidebar direction, and LTR code islands. Chapter 55, topic 2, example 5.
Example 6: Accessibility test
Check Off-Canvas Sidebar in the photo gallery with keyboard focus, zoom, reduced motion, forced colors, and high text scaling where relevant. Chapter 55, topic 2, example 6.
Example 7: Cascade test
Add a competing rule to the pricing table and determine why the declaration for Off-Canvas Sidebar wins or loses using the browser's Styles and Computed panels. Chapter 55, topic 2, example 7.
Example 8: Content-stress test
Fill the lesson sidebar with very long words, URLs, translated text, images, and nested controls. Adjust Off-Canvas Sidebar without hiding meaningful content. Chapter 55, topic 2, example 8.
Example 9: Refactoring test
Rewrite the contact form so Off-Canvas Sidebar uses reusable tokens, logical properties, or a component class while preserving the same behavior. Chapter 55, topic 2, example 9.
Example 10: Production review
Review Off-Canvas Sidebar in the button group for browser support, fallback behavior, RTL, small screens, print, motion preferences, and maintainability. Chapter 55, topic 2, example 10.
CSS/HTML coding example
<!-- HTML -->
<aside class="side">Menu</aside>
<style>
.side{position:fixed;inset-block:0;inset-inline-start:0;transform:translateX(-105%)}.side.open{transform:none}
</style>Step-by-step code explanation
- Identify the selector and declaration that demonstrate Off-Canvas Sidebar.
- Read the HTML structure first so you know which box or relationship the CSS is styling.
- The sidebar is kept outside the viewport until opened.
- Resize the viewport and test long translated content. Confirm that flex/grid items use min-width:0 where needed and that only code or genuinely wide content scrolls locally.
- Switch to Arabic or Persian and verify logical start/end spacing, text alignment, sidebar direction, and LTR isolation for code.
Expected result: The browser visibly demonstrates Off-Canvas Sidebar without requiring the page to exceed the viewport width. If the example contains wide code, only the code block scrolls horizontally. This expected result belongs to Chapter 55, topic 2.
Practice exercise
Build a fresh example for Off-Canvas Sidebar from Chapter 55. Change one value, inspect the computed styles, test at 320px and tablet width, translate the visible text, switch the page to RTL, and explain why the final declaration or layout behavior occurs.
55.3 Sticky Navigation
Sticky Navigation is part of the CSS system covered in Chapter 55. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size. The goal is to connect the syntax to the browser's layout and cascade decisions rather than memorize a property name.
For Sticky Navigation in Chapter 55, inspect the matched selector, computed value, containing block or formatting context, intrinsic size, and any min/max constraints. When translation is enabled, also inspect whether longer text or RTL direction changes the available inline space.
Start with one small example for Sticky Navigation, resize the viewport, increase text size, translate the label, and add a competing rule. This shows whether the technique remains predictable under real content rather than only in a fixed desktop mockup. This explanation is specific to Chapter 55, topic 3.
Concept in plain language
Sticky Navigation is part of the CSS system covered in Chapter 55. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size.
10 teaching examples
Example 1: Smallest useful case
Build a minimal search form for Sticky Navigation. Keep only the declarations needed to see the behavior clearly, then inspect the computed styles. Chapter 55, topic 3, example 1.
Example 2: Change one value
Change one important CSS value in the dashboard example for Sticky Navigation. Predict the visual difference before reloading the page. Chapter 55, topic 3, example 2.
Example 3: Narrow-screen test
Test Sticky Navigation in the photo gallery at 320px, 375px, and tablet width. Watch for min-content sizing, unwrapped text, and elements that refuse to shrink. Chapter 55, topic 3, example 3.
Example 4: Translated-text test
Translate the pricing table into a language with longer labels while using Sticky Navigation. Confirm buttons, headings, and navigation wrap without widening the page. Chapter 55, topic 3, example 4.
Example 5: Arabic/Persian test
Switch the lesson sidebar to Arabic or Persian. Verify logical spacing, start/end alignment, sidebar direction, and LTR code islands. Chapter 55, topic 3, example 5.
Example 6: Accessibility test
Check Sticky Navigation in the contact form with keyboard focus, zoom, reduced motion, forced colors, and high text scaling where relevant. Chapter 55, topic 3, example 6.
Example 7: Cascade test
Add a competing rule to the button group and determine why the declaration for Sticky Navigation wins or loses using the browser's Styles and Computed panels. Chapter 55, topic 3, example 7.
Example 8: Content-stress test
Fill the data table with very long words, URLs, translated text, images, and nested controls. Adjust Sticky Navigation without hiding meaningful content. Chapter 55, topic 3, example 8.
Example 9: Refactoring test
Rewrite the media player so Sticky Navigation uses reusable tokens, logical properties, or a component class while preserving the same behavior. Chapter 55, topic 3, example 9.
Example 10: Production review
Review Sticky Navigation in the notification for browser support, fallback behavior, RTL, small screens, print, motion preferences, and maintainability. Chapter 55, topic 3, example 10.
CSS/HTML coding example
<!-- HTML -->
<div class="demo sticky-navigation">CSS topic: Sticky Navigation</div>
<style>
.sticky-navigation {
padding: 1rem;
border: 1px solid #94a3b8;
}
</style>Step-by-step code explanation
- Identify the selector and declaration that demonstrate Sticky Navigation.
- Read the HTML structure first so you know which box or relationship the CSS is styling.
- The selector targets the demonstration for Sticky Navigation, and the declaration changes a visible part of its presentation.
- Resize the viewport and test long translated content. Confirm that flex/grid items use min-width:0 where needed and that only code or genuinely wide content scrolls locally.
- Switch to Arabic or Persian and verify logical start/end spacing, text alignment, sidebar direction, and LTR isolation for code.
Expected result: The browser visibly demonstrates Sticky Navigation without requiring the page to exceed the viewport width. If the example contains wide code, only the code block scrolls horizontally. This expected result belongs to Chapter 55, topic 3.
Practice exercise
Build a fresh example for Sticky Navigation from Chapter 55. Change one value, inspect the computed styles, test at 320px and tablet width, translate the visible text, switch the page to RTL, and explain why the final declaration or layout behavior occurs.
55.4 Responsive Menus
Responsive Menus is part of the CSS system covered in Chapter 55. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size. The goal is to connect the syntax to the browser's layout and cascade decisions rather than memorize a property name.
For Responsive Menus in Chapter 55, inspect the matched selector, computed value, containing block or formatting context, intrinsic size, and any min/max constraints. When translation is enabled, also inspect whether longer text or RTL direction changes the available inline space.
Start with one small example for Responsive Menus, resize the viewport, increase text size, translate the label, and add a competing rule. This shows whether the technique remains predictable under real content rather than only in a fixed desktop mockup. This explanation is specific to Chapter 55, topic 4.
Concept in plain language
Responsive Menus is part of the CSS system covered in Chapter 55. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size.
10 teaching examples
Example 1: Smallest useful case
Build a minimal pricing table for Responsive Menus. Keep only the declarations needed to see the behavior clearly, then inspect the computed styles. Chapter 55, topic 4, example 1.
Example 2: Change one value
Change one important CSS value in the lesson sidebar example for Responsive Menus. Predict the visual difference before reloading the page. Chapter 55, topic 4, example 2.
Example 3: Narrow-screen test
Test Responsive Menus in the contact form at 320px, 375px, and tablet width. Watch for min-content sizing, unwrapped text, and elements that refuse to shrink. Chapter 55, topic 4, example 3.
Example 4: Translated-text test
Translate the button group into a language with longer labels while using Responsive Menus. Confirm buttons, headings, and navigation wrap without widening the page. Chapter 55, topic 4, example 4.
Example 5: Arabic/Persian test
Switch the data table to Arabic or Persian. Verify logical spacing, start/end alignment, sidebar direction, and LTR code islands. Chapter 55, topic 4, example 5.
Example 6: Accessibility test
Check Responsive Menus in the media player with keyboard focus, zoom, reduced motion, forced colors, and high text scaling where relevant. Chapter 55, topic 4, example 6.
Example 7: Cascade test
Add a competing rule to the notification and determine why the declaration for Responsive Menus wins or loses using the browser's Styles and Computed panels. Chapter 55, topic 4, example 7.
Example 8: Content-stress test
Fill the language selector with very long words, URLs, translated text, images, and nested controls. Adjust Responsive Menus without hiding meaningful content. Chapter 55, topic 4, example 8.
Example 9: Refactoring test
Rewrite the course card so Responsive Menus uses reusable tokens, logical properties, or a component class while preserving the same behavior. Chapter 55, topic 4, example 9.
Example 10: Production review
Review Responsive Menus in the navigation bar for browser support, fallback behavior, RTL, small screens, print, motion preferences, and maintainability. Chapter 55, topic 4, example 10.
CSS/HTML coding example
<!-- HTML -->
<div class="demo responsive-menus">CSS topic: Responsive Menus</div>
<style>
.responsive-menus {
padding: 1rem;
border: 1px solid #94a3b8;
}
</style>Step-by-step code explanation
- Identify the selector and declaration that demonstrate Responsive Menus.
- Read the HTML structure first so you know which box or relationship the CSS is styling.
- The selector targets the demonstration for Responsive Menus, and the declaration changes a visible part of its presentation.
- Resize the viewport and test long translated content. Confirm that flex/grid items use min-width:0 where needed and that only code or genuinely wide content scrolls locally.
- Switch to Arabic or Persian and verify logical start/end spacing, text alignment, sidebar direction, and LTR isolation for code.
Expected result: The browser visibly demonstrates Responsive Menus without requiring the page to exceed the viewport width. If the example contains wide code, only the code block scrolls horizontally. This expected result belongs to Chapter 55, topic 4.
Practice exercise
Build a fresh example for Responsive Menus from Chapter 55. Change one value, inspect the computed styles, test at 320px and tablet width, translate the visible text, switch the page to RTL, and explain why the final declaration or layout behavior occurs.
55.5 RTL Off-Canvas Positioning
RTL Off-Canvas Positioning is part of the CSS system covered in Chapter 55. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size. The goal is to connect the syntax to the browser's layout and cascade decisions rather than memorize a property name.
For RTL Off-Canvas Positioning in Chapter 55, inspect the matched selector, computed value, containing block or formatting context, intrinsic size, and any min/max constraints. When translation is enabled, also inspect whether longer text or RTL direction changes the available inline space.
Start with one small example for RTL Off-Canvas Positioning, resize the viewport, increase text size, translate the label, and add a competing rule. This shows whether the technique remains predictable under real content rather than only in a fixed desktop mockup. This explanation is specific to Chapter 55, topic 5.
Concept in plain language
RTL Off-Canvas Positioning is part of the CSS system covered in Chapter 55. The key is to understand what box, selector, cascade rule, layout algorithm, or user preference the declaration affects, then test the result at more than one viewport size.
10 teaching examples
Example 1: Smallest useful case
Build a minimal button group for RTL Off-Canvas Positioning. Keep only the declarations needed to see the behavior clearly, then inspect the computed styles. Chapter 55, topic 5, example 1.
Example 2: Change one value
Change one important CSS value in the data table example for RTL Off-Canvas Positioning. Predict the visual difference before reloading the page. Chapter 55, topic 5, example 2.
Example 3: Narrow-screen test
Test RTL Off-Canvas Positioning in the media player at 320px, 375px, and tablet width. Watch for min-content sizing, unwrapped text, and elements that refuse to shrink. Chapter 55, topic 5, example 3.
Example 4: Translated-text test
Translate the notification into a language with longer labels while using RTL Off-Canvas Positioning. Confirm buttons, headings, and navigation wrap without widening the page. Chapter 55, topic 5, example 4.
Example 5: Arabic/Persian test
Switch the language selector to Arabic or Persian. Verify logical spacing, start/end alignment, sidebar direction, and LTR code islands. Chapter 55, topic 5, example 5.
Example 6: Accessibility test
Check RTL Off-Canvas Positioning in the course card with keyboard focus, zoom, reduced motion, forced colors, and high text scaling where relevant. Chapter 55, topic 5, example 6.
Example 7: Cascade test
Add a competing rule to the navigation bar and determine why the declaration for RTL Off-Canvas Positioning wins or loses using the browser's Styles and Computed panels. Chapter 55, topic 5, example 7.
Example 8: Content-stress test
Fill the article with very long words, URLs, translated text, images, and nested controls. Adjust RTL Off-Canvas Positioning without hiding meaningful content. Chapter 55, topic 5, example 8.
Example 9: Refactoring test
Rewrite the profile panel so RTL Off-Canvas Positioning uses reusable tokens, logical properties, or a component class while preserving the same behavior. Chapter 55, topic 5, example 9.
Example 10: Production review
Review RTL Off-Canvas Positioning in the search form for browser support, fallback behavior, RTL, small screens, print, motion preferences, and maintainability. Chapter 55, topic 5, example 10.
CSS/HTML coding example
<!-- HTML -->
<aside dir="rtl" class="side">منو</aside>
<style>
[dir="rtl"] .side{inset-inline-start:0;transform:translateX(105%)}[dir="rtl"] .side.open{transform:none}
</style>Step-by-step code explanation
- Identify the selector and declaration that demonstrate RTL Off-Canvas Positioning.
- Read the HTML structure first so you know which box or relationship the CSS is styling.
- The translation direction reverses the off-canvas transform.
- Resize the viewport and test long translated content. Confirm that flex/grid items use min-width:0 where needed and that only code or genuinely wide content scrolls locally.
- Switch to Arabic or Persian and verify logical start/end spacing, text alignment, sidebar direction, and LTR isolation for code.
Expected result: The browser visibly demonstrates RTL Off-Canvas Positioning without requiring the page to exceed the viewport width. If the example contains wide code, only the code block scrolls horizontally. This expected result belongs to Chapter 55, topic 5.
Practice exercise
Build a fresh example for RTL Off-Canvas Positioning from Chapter 55. Change one value, inspect the computed styles, test at 320px and tablet width, translate the visible text, switch the page to RTL, and explain why the final declaration or layout behavior occurs.
Chapter 55 review — 10 questions and answers
1. What should you inspect first when Mobile Navigation does not work as expected?
Answer: Inspect the matched rules, computed value, box size, layout context, and inherited values for Mobile Navigation. Then reduce the example until the winning declaration is clear.
2. How should Mobile Navigation be checked before publishing?
Answer: Test Mobile Navigation on narrow and wide screens, with long translated text, at increased zoom, and in RTL where direction can affect layout. Add a fallback if browser support or user preferences require one.
3. What should you inspect first when Off-Canvas Sidebar does not work as expected?
Answer: Inspect the matched rules, computed value, box size, layout context, and inherited values for Off-Canvas Sidebar. Then reduce the example until the winning declaration is clear.
4. How should Off-Canvas Sidebar be checked before publishing?
Answer: Test Off-Canvas Sidebar on narrow and wide screens, with long translated text, at increased zoom, and in RTL where direction can affect layout. Add a fallback if browser support or user preferences require one.
5. What should you inspect first when Sticky Navigation does not work as expected?
Answer: Inspect the matched rules, computed value, box size, layout context, and inherited values for Sticky Navigation. Then reduce the example until the winning declaration is clear.
6. How should Sticky Navigation be checked before publishing?
Answer: Test Sticky Navigation on narrow and wide screens, with long translated text, at increased zoom, and in RTL where direction can affect layout. Add a fallback if browser support or user preferences require one.
7. What should you inspect first when Responsive Menus does not work as expected?
Answer: Inspect the matched rules, computed value, box size, layout context, and inherited values for Responsive Menus. Then reduce the example until the winning declaration is clear.
8. How should Responsive Menus be checked before publishing?
Answer: Test Responsive Menus on narrow and wide screens, with long translated text, at increased zoom, and in RTL where direction can affect layout. Add a fallback if browser support or user preferences require one.
9. What should you inspect first when RTL Off-Canvas Positioning does not work as expected?
Answer: Inspect the matched rules, computed value, box size, layout context, and inherited values for RTL Off-Canvas Positioning. Then reduce the example until the winning declaration is clear.
10. How should RTL Off-Canvas Positioning be checked before publishing?
Answer: Test RTL Off-Canvas Positioning on narrow and wide screens, with long translated text, at increased zoom, and in RTL where direction can affect layout. Add a fallback if browser support or user preferences require one.