Skip to content

Commit

Permalink
Add section to responsive navigation docs explaining how to prevent F…
Browse files Browse the repository at this point in the history
…OUC, closes #7083
  • Loading branch information
gakimball committed Feb 15, 2016
1 parent cb2237d commit fc77712
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions docs/pages/responsive-navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,45 @@ By default, the title bar will be visible on small screens, and the Menu hides.
</div>
</div>
```

---

### Preventing FOUC

Before the JavaScript on your page loads, you'll be able to see both the mobile and desktop element at once for a brief second. This is known as a [flash of unstyled content](https://en.wikipedia.org/wiki/Flash_of_unstyled_content). There's not an easy way for the framework to handle this for you, but you can add some extra CSS to account for it.

If we reference the above example, `.title-bar` is our mobile element and `.top-bar` is our desktop element. So before the JavaScript loads, we want only the right element for that screen size to be visible.

```css
.no-js .top-bar {
display: none;
}

@media screen and (min-width: 40em) {
.no-js .top-bar {
display: block;
}

.no-js .title-bar {
display: none;
}
}
```

If you're using Sass, you can write it like this:

```scss
.no-js {
@include breakpoint(small only) {
.top-bar {
display: none;
}
}

@include breakpoint(medium) {
.title-bar {
display: none;
}
}
}
```

0 comments on commit fc77712

Please sign in to comment.