Build it yourself - Header
Ta treść nie jest jeszcze dostępna w Twoim języku.
Since your site will be viewed on different devices, it’s time to create a page navigation that can respond to multiple screen sizes!
Przygotuj się na…
- Create a Header for your site that contains the Navigation component
- Make the Navigation component responsive
Try it yourself - Build a new Header component
Section titled Try it yourself - Build a new Header component-
Create a new Header component. Import and use your existing
Navigation.astro
component inside a<nav>
element which is inside a<header>
element.Show me the code!
Create a file named
Header.astro
insrc/components/
src/components/Header.astro ---import Navigation from './Navigation.astro';---<header><nav><Navigation /></nav></header>
Try it yourself - Update your pages
Section titled Try it yourself - Update your pages-
On each page, replace your existing
<Navigation/>
component with your new header.Show me the code!
src/pages/index.astro ---import Navigation from '../components/Navigation.astro';import Header from '../components/Header.astro';import Footer from '../components/Footer.astro';import '../styles/global.css';const pageTitle = "Home Page";---<html lang="en"><head><meta charset="utf-8" /><link rel="icon" type="image/svg+xml" href="/favicon.svg" /><meta name="viewport" content="width=device-width" /><meta name="generator" content={Astro.generator} /><title>{pageTitle}</title></head><body><Navigation /><Header /><h1>{pageTitle}</h1><Footer /></body></html>