I need to create header and footer fixed for all pages

Asked

Viewed 5,335 times

3

I’m a beginner in programming and I’m not able to insert header and footer fixed on all pages of the site. I saw here on the site an option with Renderboy and Rendersection but I confess that I did not understand. The site in question is simple and has few pages. There is a simple way to do this?

1 answer

2

This code fixes the header and footer.

CSS:

footer {
 width: 100%;
 position: fixed;
 bottom: 0;
 right: 0;
 background: black;
 color: white;
 height: 40px;
 display: flex;
}
header {
 width: 100%;
 position: fixed;
 top: 0;
 left: 0;
 color: white;
 background: black;
 height: 40px;

}

HTML:

<html>
 <body>
  <header>
   Este é o cabeçalho
  </header>
   este é o corpo
  <footer>
    Este é o rodapé
  </footer>
 </body>
</html>

The important CSS rules for the desired purpose are:

position: fixed

top: 0 bottom: 0 right: 0 left: 0

They instruct the code to fix the elements and in which positions.

From this, it is easy to adapt to your case.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.