Reputation: 89
How did the material.angular.io achieved the effect where buttons from top toolbar (Component, CDK, Guide) comes to the next row as tabbar when you hit the lower breakpoint?
Upvotes: 1
Views: 212
Reputation: 386
They use two separate <nav>
elements and set display: none
on the one with class .docs-navbar-show-small
unless it is the smaller break point. They do the opposite for the top ones, displaying when the view is larger and hiding when it is smaller. So it ends up looking something like this:
HTML:
<nav class="docs-navbar-header">
<!--nav options here-->
</nav>
<nav class="docs-navbar-show-small">
<!--same nav options here-->
</nav>
CSS:
@media screen and (max-width: $breakpoint) {
.docs-navbar-header {
display: hidden;
}
.docs-navbar-show-small {
display: flex;
...
}
}
@meda screen and (min-width: $breakpoint) {
.docs-navbar-header {
display: flex;
...
}
.docs-navbar-show-small {
display: hidden
}
}
From devtools:
Upvotes: 1