search

Home  >  Q&A  >  body text

Title rewritten as: HTML element height does not reach 100% coverage

I want this element to cover 100% of the screen height, apparently it doesn't do that, is there any workaround? I see that the height of the div is 100% of the section, and the height of the section is 100% of the body, while the body is set to 100%.

<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粉359850827437 days ago536

reply all(1)I'll reply

  • P粉014293738

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

    Use this code as body:

    body {
        height: 100vh;
    }

    reply
    0
  • Cancelreply