gpt4 book ai didi

css - 高度 : 100vh; and overflow "content" on smaller screens

转载 作者:技术小花猫 更新时间:2023-10-29 11:05:08 25 4
gpt4 key购买 nike

我有一个 height: 100vh; 但我有很多内容,在较小的屏幕上会溢出到另一个“vh”,在较小的屏幕上如何处理溢出?

最佳答案

如果我没理解错的话,你有多个 height: 100vh 的元素,问题是它们的内容可能会溢出。

在这种情况下,你可以

  • 使用overflow 属性正确处理溢出。

    例如 overflow: auto 将仅在必要时添加滚动条。

    html,body {
    margin: 0;
    }
    section {
    height: 100vh;
    overflow: auto;
    background: yellow;
    }
    section + section {
    background: lime;
    }
    div {
    height: 150vh;
    margin-left: 15px;
    border-left: 1px dotted;
    }
    <section>
    Start<div></div>End
    </section>
    <section>
    Start<br />End
    </section>

  • 使用 min-height: 100vh 而不是 height: 100vh

    这样,如果内容更高,元素会增长以避免溢出。

    html,body {
    margin: 0;
    }
    section {
    min-height: 100vh;
    background: yellow;
    }
    section + section {
    background: lime;
    }
    div {
    height: 150vh;
    margin-left: 15px;
    border-left: 1px dotted;
    }
    <section>
    Start<div></div>End
    </section>
    <section>
    Start.<br />End
    </section>

关于css - 高度 : 100vh; and overflow "content" on smaller screens,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34760708/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com