rstacruz / nprogress

For slim progress bars like on YouTube, Medium, etc
http://ricostacruz.com/nprogress
MIT License
25.98k stars 1.81k forks source link

Issue with flexbox flex-grow #223

Open aegatlin opened 4 years ago

aegatlin commented 4 years ago

This could be related to #222 , but it felt different enough so I'll post it here.

We are building a Phoenix LiveView app and we have the following CSS:

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {}
footer {}
main {
  flex-grow: 1;
}

The goal is to give main a min-height of "whatever the rest of the viewport height is". However, this causes a flicker effect on page load because a div with id="nprogress" is added to the bottom of the page. This has an effect on the "remaining height" that was otherwise being allocated to main. The div is almost immediately removed, after which the page returns to normal.

I have fixed the issue with the following CSS:

#nprogress {
  max-height: 0;
}

It still shows the progress bar on the top, so it seems to be a perfect fix, since I still get the progress bar, but now don't have to deal with the flicker effect it caused.

This could be a possibly small fix to introduce for people that have display: flex on their body element, and are doing so for a reason similar to mine.