Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox ignores padding when using overflow:scroll

Tags:

css

firefox

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.

like image 348
miho Avatar asked May 01 '15 12:05

miho


People also ask

How do I get rid of scroll padding?

You can apply scrollbar-width: none to the container div. This will hide the scrollbar altogether.

What is the difference between overflow scroll and overflow auto?

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.

What is scroll padding top?

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.

What does overflow Y scroll do?

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.


2 Answers

After a bit of brainstorming with fellow developers, although not very graceful, this pure css solution works:

.container:after {     content: "";     height: 50px;     display: block; } 

Fiddle

like image 199
Arthurion Avatar answered Nov 07 '22 01:11

Arthurion


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; } 
like image 29
Nilesh Mahajan Avatar answered Nov 07 '22 02:11

Nilesh Mahajan