Home > Web Front-end > CSS Tutorial > How to Prevent Flex Children from Exceeding Parent Height with Scrollbars in Firefox?

How to Prevent Flex Children from Exceeding Parent Height with Scrollbars in Firefox?

Barbara Streisand
Release: 2024-10-25 03:03:30
Original
340 people have browsed it

How to Prevent Flex Children from Exceeding Parent Height with Scrollbars in Firefox?

Prevent Flex Item from Exceeding Parent Height with Scrollbars

Issue: In Firefox, a flex child item with scrollbars exceeds the height of its parent flex container, causing content overflow and the absence of scrollbars.

Solution:

Modify the flex property of the child items #messagelist and #messagecontents as follows:

<code class="css">#messagelist {
        flex: 1 1 1px; /* instead of flex: 1 */
    }

#messagecontents {
        flex: 1 1 1px; /* instead of flex: 1 */
    }</code>
Copy after login

Explanation:

Chrome's default behavior is to trigger overflow and generate scrollbars when the flex-basis is set to 0. Firefox and Edge, however, require a set height or max-height for overflow to occur.

By specifying a fixed height of 1px for the flex-basis, even though it's a small value, it satisfies the requirement for creating an overflow condition and enables scrollbars to appear when content exceeds the child's height.

The above is the detailed content of How to Prevent Flex Children from Exceeding Parent Height with Scrollbars in Firefox?. For more information, please follow other related articles on the PHP Chinese website!

source:php
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template