HTML/CSS: Body ist kürzer als Inhalt der Website?

1 Antwort

Was direkt auffällt ist, dass du all deine Elemente mit float aus dem normalen Textfluss der Seite nimmst. Das hat Einfluss auf die Höhenberechnung des Containers. Deswegen nimmt das body-Element nicht die volle Höhe der Kindelemente ein. Nimm es daher raus. Ich sehe nicht, wieso du es brauchen solltest.

Ebenso würde ich es vermeiden, den body in Höhe und Breite auf 100% zu begrenzen. Zumal Letzeres eine hässliche horizontale Scrollbar erzeugt.

Eine einfache Version könnte folgendermaßen aussehen:

<!doctype html>
<head>
  <meta charset="utf-8">
  <title>Example</title>
  <style>
    body {
      background: azure;
      margin: 0;
      padding: 0;
      scroll-behavior: smooth;
    }

    .marquee {
      background: yellow;
      font-size: 100px;
      font-weight: 600;
      height: 125px;
      margin-bottom: 10vh;
    }

    .navigation {
      background: white;
      box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
      margin: 0 auto 30px auto;
      padding: 1rem;
      position: sticky;
      top: 10px;
      width: 92%;
      z-index: 4;
    }

    .content-container {
      background: white;
      margin: 0 auto 50px auto;
      min-height: 300px;
      padding: 2rem;
      width: 92%;
    }
  </style>
</head>
<body>
  <section class="marquee">marquee</section>
  <nav class="navigation">navigation</nav>
  <section class="content-container">contentcontainer</section>
  <section class="marquee">marquee</section>
  <section class="content-container">contentcontainer</section>
  <section class="marquee">marquee</section>
  <section class="content-container">contentcontainer</section>
  <section class="marquee">marquee</section>
</body>

Inkognito-Nutzer   09.07.2025, 10:36

Vielen Dank. Das wars.

Ich war verwirrt weil der Inspector eine Containerhöhe angeben konnte.