When using overflow: scroll
combined with padding: /* ... */
CSS property, the padding at the bottom of the element is missing in Firefox. (But works in Chrome and Safari.)
.container { height: 100px; padding: 50px; border: solid 1px red; overflow-y: scroll; } ul, li { padding: 0; margin: 0; }
<div class="container"> <ul> <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>content</li> <li>content</li> <li>content</li> <li>content</li> <li>content</li> <li>content</li> <li>content</li> <li>content</li> <li>content</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> </ul> </div>
View Demo
Did I missed something or is there any kind of work around for this issue?
Notice: the demo doesn't use any library for normalizing, but I tried normalize.css
too, but without success.
You can apply scrollbar-width: none to the container div. This will hide the scrollbar altogether.
The difference For that, you need overflow: auto , which lets a browser automatically determine if a scroll bar is needed — or not. So in short: overflow: scroll : Always show a scroll bar. overflow: auto : Show a scroll bar when needed.
The scroll-padding-top property defines offsets for the top of the optimal viewing region of the scrollport: the region used as the target region for placing things in view of the user.
The overflow-y property specifies whether to clip the content, add a scroll bar, or display overflow content of a block-level element, when it overflows at the top and bottom edges.
After a bit of brainstorming with fellow developers, although not very graceful, this pure css solution works:
.container:after { content: ""; height: 50px; display: block; }
in Firefox padding-bottom is ignored with overflow:auto or overflow:scroll, see the documentation
https://bugzilla.mozilla.org/show_bug.cgi?id=748518
still if you want to work around your example to achieve the desired result then see the fiddle: https://jsfiddle.net/nileshmahaja/4vuaf4o3/1/
Modified CSS
.container { height: 200px; padding: 50px 50px 0; border: solid 1px red; overflow-y:auto; display:block; } ul{ padding:0 0 50px; display:block } li { padding: 0; margin: 0; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With