Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

sticky footer issue with flex-basis #544

Closed
mattiLeBlanc opened this issue Jan 2, 2018 · 13 comments · Fixed by #669
Closed

sticky footer issue with flex-basis #544

mattiLeBlanc opened this issue Jan 2, 2018 · 13 comments · Fixed by #669
Assignees
Labels
bug has pr A PR has been created to address this issue P1 Urgent issue that should be resolved before the next re-lease

Comments

@mattiLeBlanc
Copy link

mattiLeBlanc commented Jan 2, 2018

Bug, feature request, or proposal:

Checking my app on IE10-11 uncovered I was see an issue with my sticky footer. It was not sticky, but just say under the content block positioned above:

+site(fxLayout="column" fxFlex)
  |- header
  |- content(fxFlex)
  |- footer
==white-space==

So I went back to the article written by Philip Walton a couple of years ago, https://philipwalton.com/articles/normalizing-cross-browser-flexbox-bugs/, and implemented his fix.

However, I was a bit puzzled that this fix is still required nowadays.
So I was wondering if we still need to do this:

+site(fxLayout="column" fxFlex) --> add height: 100%
  |- header  --> add flex-shrink: 0
  |- content(fxFlex)  --> add flex: 1 0 auto
  |- footer -->add flex-shrink: 0

Only if I add the flex:1 0 auto to the content block, will it work fine in Chrome. I am actually overriding fxFlex at this moment.

What is the expected behavior?

Header at top, content stretched and footer sticky at the bottom.

What is the current behavior?

In IE10-11 footer is not sticky at bottom. When adding height 100% to site, then Chrome will squeeze the content block so that everything will fit. Fix on, break the other and vice versa.

@CaerusKaru
Copy link
Member

IE10 is not supported by Flex Layout. If this is also an issue with IE11, please provide a StackBlitz/Plunkr minimal reproduction so that we can check this out. There were some rumblings that we may change the fxFlex directive to use auto, which as you mentioned may fix this issue.

@CaerusKaru CaerusKaru added IE Bug This issue is specific to Internet Explorer needs: demo labels Jan 2, 2018
@mattiLeBlanc
Copy link
Author

I created a stackblitz:
https://stackblitz.com/edit/angular-txxdrw

This is based on on my project but simplified. IE11 is working fine with my current setup.
I had to add .fxFlex via hostbindig to my components that run in the router-outlet.
Also putting a height:100vh; on my app.component help scale the viewport.
I will look back through my own project and see if I can recreate the issue there and see how it differs to the stackblitz.
It came down to the footer not sticking because the body part wasn't stretching. But I am not seeing that behaviour right now.
I look into it after lunch.

@mattiLeBlanc
Copy link
Author

mattiLeBlanc commented Jan 3, 2018

okay, I found the issue again. It has to do with Chrome allowing its elements to shrink below 1.

So one issue is visisble here:
https://stackblitz.com/edit/angular-nignbs
When you make the page vertically smaller and scroll you will see the footer will start to float.

The fix is in the styles.css (in the root) where I define .fxFlex. Using flex: 1 0 auto; makes the footer behave correctly in combination with the flex-shrink 0 on the header and the footer.
I checked and IE11 shows the same behaviour. With auto it works, without it doesnt.

Same on Safari and I assume FF.

So I guess my issue is not 100% an IE bug but more a bug that Chrome allows content to shrink beyond the minimal height, illustrater here:

image

When I apply the flex-shrink 0 to header and footer and flex: 1 0 auto to the body, it scrolls normally.
And it would like like:

image

@mattiLeBlanc
Copy link
Author

mattiLeBlanc commented Jan 3, 2018

Hmm, I just create another fork where I got rid of the flex-shrink 0 on the head and footer.
https://stackblitz.com/edit/angular-pfbyv3

It still works for the footer.
So the flex: 1 0 auto on the my-app apparently is the most important factor.

However (finally found out why :) in Chrome it allows for the squeezing of the body content into the header (like you see in the sxreenshot above).

@CaerusKaru CaerusKaru added bug and removed IE Bug This issue is specific to Internet Explorer labels Jan 3, 2018
@CaerusKaru
Copy link
Member

Ok then that's to be expected, we'll try to get a fix in for this as soon as we can.

@CaerusKaru CaerusKaru changed the title sticky footer issue (flex shrink( sticky footer issue with flex-basis Jan 3, 2018
@mattiLeBlanc
Copy link
Author

I hope I am not confusing you :).
It's just that there are a lot of different scenario's and browsers. I always lose track what happens when and on what browser. But I seem to be getting closer now.

@CaerusKaru
Copy link
Member

@ThomasBurleson alluded to a fix for this in #481 (comment). I don't think the PR was ever opened, but should be soon.

@CaerusKaru CaerusKaru added this to the v2.0.0-beta.13 milestone Jan 3, 2018
@CaerusKaru CaerusKaru added the P1 Urgent issue that should be resolved before the next re-lease label Jan 3, 2018
@ThomasBurleson
Copy link
Contributor

This is related to on-going work to improve usages with flex-basis (see issue #438)

@probert94
Copy link

Also putting a height:100vh; on my app.component help scale the viewport.

Not related to this Issue, but @mattiLeBlanc be aware, that on many mobile browsers (including Chrome for Android) the 100vh are inclusive the URL-Bar, so the container you set to 100vh will be scrollable!

@abdulloh-abid
Copy link

thanks @mattiLeBlanc for sharing your solution, it works great!
If anybody is still interested in for sticky footer, I found simpler solution here , credit to David Kerwick

@mattiLeBlanc
Copy link
Author

@ThomasBurleson Thanks to you and the team for your efforts of getting these issues resolved!

@ThomasBurleson
Copy link
Contributor

@mattiLeBlanc - Thank you. Note that we are still working/tweaking improvements for fxFlex. And more REALLY COOL things are coming in April.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug has pr A PR has been created to address this issue P1 Urgent issue that should be resolved before the next re-lease
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants