Home > Web Front-end > CSS Tutorial > Why Does Firefox Hide Padding on Scrolling Overflow Containers, and How Can We Fix It?

Why Does Firefox Hide Padding on Scrolling Overflow Containers, and How Can We Fix It?

Barbara Streisand
Release: 2024-10-26 03:36:27
Original
1109 people have browsed it

Why Does Firefox Hide Padding on Scrolling Overflow Containers, and How Can We Fix It?

Why Does Firefox Hide Padding on Scrolling Overflow Containers?

Firefox deviates from other browsers when using the overflow: scroll property combined with padding on an element. In Firefox, the padding at the bottom of the element disappears, creating a discrepancy in rendering.

Identifying the Issue

Consider the following code:

<code class="css">.container {
  height: 100px;
  padding: 50px;
  border: solid 1px red;
  overflow-y: scroll;
}</code>
Copy after login
<code class="html"><div class="container">
  <ul>
    <!-- ... list items ... -->
  </ul>
</div></code>
Copy after login

In Chrome and Safari, the container's bottom padding is correctly displayed, but in Firefox, it vanishes.

Solving the Issue

After collaborating with other developers, we found a workaround using pure CSS:

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

This adds an empty element after the container, effectively replicating the missing padding.

Demonstration

Try the fiddle below to see the solution in action:

[Fiddle]()

Conclusion

While not an ideal solution, this workaround addresses the issue of disappearing bottom padding in Firefox when using overflow: scroll.

The above is the detailed content of Why Does Firefox Hide Padding on Scrolling Overflow Containers, and How Can We Fix It?. 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