question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ionic scroll doesn't observe bottom margin of last-child

See original GitHub issue

(I wonder if this issue hasn’t been addressed elsewhere, since it quite leaps to the eye?)

Look at the scroll element that is translated when using Ionic’s custom scroll implementation. It’s a simple container with no special overflow or padding properties – thus, when its last-child has margin-bottom, it is subject to margin-collapsing.

On most any page I can think of, the last child element has margin-bottom; it could be a list-inset element or a card. However, due to the rules of collapsing margins, this margin ends up outside the parent scroll-container without the latter changing its height.

So, when reaching the bottom of the scroll, the bottom margin of the last element (20px by default) isn’t shown – the element is flush with the bottom edge of the view, looking pretty cramped (I’ve actually only looked at this in an app with bottom tabs).

Setting overflow: hidden on the scroll container would prevent this from happening. I wonder whether this would have any bad side-effects?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dalgardcommented, Aug 30, 2014

I see exactly what the problem is:

In your excellent example, you’ve put the cards inside an <ion-list> (same as putting them inside a <div class="list">, I suppose). The list element makes sure their margins don’t collapse with <ion-content> by having its padding-top and padding-bottom set to 1px.

The documentation doesn’t mention the containing list element at all and I see a couple of reasons why one would think that the card elements go directly inside <ion-content> – one being that cards themselves in many cases get a list class, and another that they are put directly inside a content element in the right side preview.

I don’t mean to say that there’s anything illogical about having the cards inside a list, of course, but it should probably be explicated. (Also, I don’t expect people to inspect the preview pane with devtools, but some might… 😉)

0reactions
ionitron-bot[bot]commented, Sep 6, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ionic scroll doesn't observe bottom margin of last-child #2047
It's a simple container with no special overflow or padding properties – thus, when its last-child has margin-bottom , it is subject to...
Read more >
ion-scroll scroll to the bottom won't show all the items at the ...
1 Answer 1 ... I think the better way is use <ion-content> , this was designed for scrolling as well. But it has...
Read more >
[Ionic V4]How to remove last-child bottom border of ion-item in ...
In this case, when advanceOpts is true, last item is Item4, else Item2. In other cases, any one may be the last item,...
Read more >
overscroll-behavior - CSS: Cascading Style Sheets | MDN
The overscroll-behavior CSS property sets what a browser does when reaching the boundary of a scrolling area.
Read more >
box-sizing - CSS-Tricks
The box-sizing property in CSS controls how the box model is handled for the element it applies to.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found