Heim  >  Fragen und Antworten  >  Hauptteil

Titel umgeschrieben als: Höhe des HTML-Elements erreicht nicht 100 % Abdeckung

Ich möchte, dass dieses Element 100 % der Bildschirmhöhe abdeckt. Offenbar funktioniert das nicht. Gibt es eine Lösung? Ich sehe, dass die Höhe des Div 100 % des Abschnitts und die Höhe des Abschnitts 100 % des Körpers beträgt, während der Körper auf 100 % eingestellt ist.

<body>
    <section id="Block1">
        <div class="firstsection">
            <h1>Lorem Ipsum</h1>
            <p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nemo magnam iusto quibusdam quas reiciendis fugit architecto consequatur similique distinctio dolore repudiandae rem illo alias iure sunt eos culpa, amet consectetur!</p>
        </div>
    </section>
</body>

CSS

body {
    width: 100%;
    height: 100%;
}
* {
    padding: 0px;
    margin: 0px;
}
.firstsection {
    width: 50%;
    height: 100%;
    background-color: yellowgreen;
    text-align: center;
}
#Block1 {
    width: 100%;
    height: 100%;
}

P粉359850827P粉359850827370 Tage vor472

Antworte allen(1)Ich werde antworten

  • P粉014293738

    P粉0142937382023-09-16 00:37:32

    使用此代码作为body:

    body {
        height: 100vh;
    }

    Antwort
    0
  • StornierenAntwort