Home > Web Front-end > CSS Tutorial > Why Does Firefox Omit Padding at the Bottom of Elements with Overflow: Scroll?

Why Does Firefox Omit Padding at the Bottom of Elements with Overflow: Scroll?

Patricia Arquette
Release: 2024-10-27 04:48:29
Original
1061 people have browsed it

Why Does Firefox Omit Padding at the Bottom of Elements with Overflow: Scroll?

Troubleshooting Firefox's Padding Omission with Overflow

When implementing both overflow: scroll and padding CSS properties, users may encounter an issue where Firefox suppresses the padding at the element's bottom, unlike browsers such as Chrome and Safari.

Problem Scenario:

`


    <li>padding above first line in every Browser</li>
    <li>content</li>
    <li>content</li>
    ...
    <li>content</li>
    <li>content</li>
    <li>content</li>
    <li>no padding after last line in Firefox</li>
    Copy after login


`

In this snippet, the element has a height of 100px, a padding of 50px, a red border, and vertical scroll overflow. However, in Firefox, the padding at the bottom of the container is missing, creating an unexpected appearance.

Workaround:

While this issue may seem perplexing, a relatively simple pure CSS solution can resolve it:

<code class="css">.container:after {
    content: "";
    height: 50px;
    display: block;
}</code>
Copy after login

By adding this CSS rule, you insert an empty element with a height equal to the container's padding. This element serves as a placeholder, ensuring that the padding is consistently maintained even with scroll overflow.

Demonstration:

[Fiddle](https://jsfiddle.net/rdx8k4mz/) showcasing the workaround.

The above is the detailed content of Why Does Firefox Omit Padding at the Bottom of Elements with Overflow: Scroll?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
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