Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

225
Visualizações
Angular: Page overflows when height of both html and body is set to 100%

I'm developing a SPA using Angular, and I have specified html, body { height: 100% } and body { margin: 0 } in CSS. In this situation, if I use HTML tags with default margins in a component, such as <h1> tag, the page will overflow.

This seems to be due to the fact that the margin of the first element of body is replaced by the margin of the body, which is different from the behavior in plain HTML. In plain HTML, the top margin of the first element is ignored, and the body never has a margin. However, this behavior is not the case in Angular (or React, to be precise).

What is the cause of this?
Also, is there any way to achieve the normal HTML behavior in Angular?

Samples in Stack Blitz are as follows:

  • Plain HTML: https://stackblitz.com/edit/web-platform-x6cd4l?file=index.html
  • Angular: https://stackblitz.com/edit/angular-ivy-2yrmkw?file=src/app/app.component.ts
  • React: https://stackblitz.com/edit/react-ts-4mdnyl?file=index.tsx

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Looks like it's your HTML version is missing <!DOCTYPE html>, so it's being rendered differently. And the overflow is caused by the H1 having a top margin, causing a margin between the body and html.

Once you've added the doctype you can then set margin-top: 0 for h1 and the problem should no longer exist.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda