mat-sidenav(mat-sidenav-container) covers mat-sidenav-content - css

app.component.ts
<router-outlet></router-outlet>
nav-landing.component.html
I have a component that contains my mat-toolbar and my mat-sidenav-container. The menu to toggle to side nav is only shown on smaller devices.
<mat-toolbar ngClass="transparent-nav">
<div>
<mat-radio-group aria-label="Select a country">
<mat-radio-button value="All" [checked]="true" aria-label="All countries">All
</mat-radio-button>
<mat-radio-button value="C" aria-label="Country" [disabled]="true">North America
<mat-menu #cornwallOptions="matMenu">
<button mat-menu-item *ngFor="let n of northCountries" (click)="selectNorthAmerica(n)">
{{ n.country }}
</button>
</mat-menu>
</mat-radio-button>
</mat-radio-group>
<button mat-icon-button ngClass="btn-toggle">
<mat-icon (click)="sidenav.toggle()">
menu
</mat-icon>
</button>
</div>
</mat-toolbar>
<mat-sidenav-container>
<mat-sidenav #sidenav position="end">
<mat-accordion>
<mat-expansion-panel [disabled]="true" hideToggle (click)="selectAllCountries()">
<mat-expansion-panel-header>
All
</mat-expansion-panel-header>
</mat-expansion-panel>
<mat-expansion-panel [disabled]="true">
<mat-expansion-panel-header class="disabledExpansionPanel">
North Countries
</mat-expansion-panel-header>
<mat-nav-list>
<mat-list-item *ngFor="let n of northCountries" (click)="selectNorthAmerica(n)"> {{ n.country }}
</mat-list-item>
</mat-nav-list>
</mat-expansion-panel>
</mat-accordion>
</mat-sidenav>
<mat-sidenav-content>
<div ngClass="content">
<router-outlet></router-outlet>
</div>
</mat-sidenav-content>
</mat-sidenav-container>
landing.component.html
I then call my nav bar inside my landing page.
<header>
<app-nav-landing></app-nav-landing>
</header>
<main ngClass="landing-main-bg">
<div ngClass="container">
<div ngClass="row justify-content-center align-items-center ">
<div ngClass="col-md-5">
<div ngClass="section-center">
<div ngClass="main-heading">
<app-search-box></app-search-box>
</div>
</div>
<div>
</div>
</div>
<div>
</div>
</div>
</div>
</main>
<app-footer></app-footer>
While testing I realized that the sidebar did not show when I clicked the menu. I later found out that it was being hidden so I added this CSS below and then the sidemenu started to show.
.mat-sidenav-container {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: transparent;
}
However, I now realize that because of the position absolute the I am now longer able to type in the search box component because the mat-sidenav-container is now covering it. Once I remove the positional absolute I can search but I need position absolute to show the nav bar.
How do I stop the mat-sidenav-container from covering the other components?

Related

CSS Flexbox - Align the contents on top and align the button to bottom

I'm trying to modify an existing component which inherits the Flexbox concept.
Currently it looks like this:
Now what I'm trying to achieve is regardless of content size inside the box:
The box will have the same height - aligned to each other
The button will stay at the bottom even if the top contents are long.
Here is the existing structure that I'm trying to fix:
<section class="container counsellor-list">
<div class="row">
<div class="col-12 col-sm-12 col-lg-6 col-xl-4 mb-30 counsellor-list-item">
<div class="state_chosen">
<img class="img-fluid" src="https://st.depositphotos.com/1771835/1477/i/950/depositphotos_14779771-stock-photo-portrait-of-confident-young-doctor.jpg" />
<div class="bg-blue20 p-30 counsellor-list-item-content">
<div class="text-coral subtitle-small text-bold text-uppercase mb-24 d-flex flex-wrap">
<span class="">
Wien
</span>
<span class="ml-16">
St. Polten
</span>
<span class="ml-auto language">
<span>
DE
<span> | </span>
EN
</span>
</span>
</div>
<h2 class="mb-24">Jan Faustio</h2>
<div class="">
<a class="btn btn-coral" href="#"> Button </a>
</div>
</div>
</div>
</div>
...
</section>
Codepen link
I tried a lot of stuff but didn't work as I'm expecting it to be/result.
Check this, I hope I understood what you want to achieve https://codepen.io/IvanBisultanov/pen/PoQmXqX
I also added .btn-wrap classname, and wrapped all HTML above in div
.counsellor-list-item-content {
flex-grow: 1;
display: flex;
flex-direction: column;
}
.btn-wrap {
margin-top: auto;
}

How can I adjust the height of ion-card?

I'm working on a QuizSelectionComponent using Ionic. I need to adjust the ion-card's height to fit all the content in the card, longer than the height of my laptop screen. I've tried adding height: 100% !important;, height: auto !important; and height: 100vh !important; in my CSS file; but none seem to increase the height of the card. Is there a setting I can override somewhere?
My QuizSelectionComponent template looks like:
<ng-container *ngIf="quizData.length > 0">
<ion-card style="height: 100vh">
<ion-card-header>
<div class="container">
<div class="col-2 col-sm-2 col-md-2 col-lg-2 col-xl-2 logo">
<div ion-card-avatar class="header-image"></div>
</div>
<div class="col-8 col-sm-8 col-md-8 col-lg-8 col-xl-8">
<ion-card-title i18n>
<h1>Quiz App</h1>
</ion-card-title>
<ion-card-subtitle i18n>
<span>How well do you know Angular? Find out!</span>
</ion-card-subtitle>
</div>
<div class="col-2 col-sm-2 col-md-2 col-lg-2 col-xl-2 info">
<ion-icon name="information-circle-outline"></ion-icon>
</div>
</div>
</ion-card-header>
<section class="ion-card-content">
<mat-toolbar>
<mat-menu-button mat-button [matMenuTriggerFor]="menu">
<span i18n>Milestones ▼</span>
</mat-menu-button>
<mat-menu #menu="matMenu">
<div *ngFor="let quiz of quizData">
<button mat-menu-item
[routerLink]="['/intro/', quiz.quizId]"
data-i18n="quiz.milestone">{{ quiz.milestone }}</button>
</div>
</mat-menu>
</mat-toolbar>
<mat-grid-list cols="3" rowHeight="370px">
<mat-grid-tile
(click)="onClick()"
*ngFor="let quiz of quizData"
[routerLink]="['/intro/', quiz.quizId]"
[ngClass]="{ 'completed': status === 'completed' }"
[ngStyle]="{ 'background': 'url(' + quiz?.imageUrl + ') no-repeat center 10px',
'background-size': '300px 210px' }">
<summary class="quiz-info">...</summary>
<div class="status-icon">...</div>
</mat-grid-tile>
</mat-grid-list>
</section>
<ion-footer>
<h3 class="text-center" i18n>© 2020</h3>
</ion-footer>
</ion-card>
</ng-container>
Have you tried with: height: 100vh;
vh: Relative to 1% of the height of the viewport
https://www.w3schools.com/cssref/css_units.asp

Ionic 4 - Ion-footer goes transparent when ion-refresh is used

I tried adding a ion-refresher to my app, but when i pull to refresh, the ion-footer goes transparent.
Code:
<ion-content padding color="primary">
<ion-refresher slot="fixed" (ionRefresh)="doRefresh($event)">
<ion-refresher-content color="primary" pullingIcon="arrow-dropdown" pullingText="Pull to refresh" refreshingSpinner="circles" refreshingText="Refreshing...">
</ion-refresher-content>
</ion-refresher>
<div *ngFor="let weather of weather_data">
.......
</ion-content>
<ion-footer>
<ion-toolbar color="white">
<div class="tabs">
<div class="tab">
<ion-icon name="keypad"></ion-icon>
<div class="label">Input</div>
</div>
<div class="tab">
<ion-icon name="person"></ion-icon>
<div class="label">Account</div>
</div>
<div class="tab">
<ion-icon name="log-out"></ion-icon>
<div class="label">Log Out</div>
</div>
</div>
</ion-toolbar>
</ion-footer>
Fixed it, i just removed the color attribute in the footer. Thanks anyway

Angular Flex Layout Always shows scrollbar

I am new to angular and flex layout. My Page is pretty simple. Header with side navbar and router outlet.
I ran into the issue that my Page always shows a scrollbar.
If I remove fxFlexFill, scrollbar not showing. How can I fix this?
Here is stackblitz demo Stackblitz
Here is my template:
.fill-space {
flex: 1 1 auto;
}
.content {
flex: 1 1 auto;
padding: 15px;
position: relative;
overflow-y: auto;
}
.footer {
display: flex;
flex: 1 0 auto;
justify-content: center;
}
<div style="height: 100vh;">
<mat-toolbar color="primary" class="fixed-header">
<mat-toolbar-row>
<button mat-icon-button (click)="sidenav.toggle()" fxShow="true" fxHide.gt-sm>
<mat-icon>menu</mat-icon>
</button>
<span><button mat-button routerLink="/home"><h3>HOSPITALITY</h3></button></span>
<span class="fill-space"></span>
<div fxShow="true" fxHide.lt-md="true">
<button mat-button routerLink="/home">HOME</button>
<button mat-button routerLink="/account">MY ACCOUNT</button>
<button mat-button routerLink="/login">LOGOUT</button>
<a href="#" routerLink="/cart" mat-button>
<mat-icon>shopping_cart</mat-icon>
0
</a>
</div>
</mat-toolbar-row>
</mat-toolbar>
<mat-sidenav-container fxFlexFill>
<mat-sidenav #sidenav fxLayout="column" mode="over" opened="false" fxHide.gt-sm="true">
<div fxLayout="column">
<button mat-button routerLink="/home">HOME</button>
<button mat-button routerLink="/account">MY ACCOUNT</button>
<button mat-button routerLink="/login">LOGOUT</button>
<a href="#" routerLink="/cart" mat-button>
<mat-icon>shopping_cart</mat-icon>
0
</a>
<a (click)="sidenav.toggle()" mat-list-item>
<mat-icon>close</mat-icon> Close
</a>
</div>
</mat-sidenav>
<mat-sidenav-content >
<div class="content">
<router-outlet></router-outlet>
</div>
</mat-sidenav-content>
</mat-sidenav-container>
</div>
The main issue is that the side nav gets a height of 100vh via the fxFlexFill directive.
You need to take into account the height of mat-toolbar-row, for example, by CSS calc (there are other ways to achieve his effect, depends on how you struct page layout)
Additionally, the body has an 8px margin, from the browser default style.
Here is a fork of Stackblitz

How can I left align the text in an Angular Material stretched md-button?

Without tinkering too much with my own CSS, Is there an attribute or configuration I can use to left align the text in a md-button that is stretched a bit to fit a menu for example?
This is my current view
<md-sidenav md-is-locked-open="$mdMedia('gt-md')" layout="column">
<md-toolbar>
<h1 class="md-toolbar-tools">
<a ng-href="/" layout="row" href="/">
<div class="docs-logotype">Material Design</div>
</a>
</h1>
</md-toolbar>
<md-content flex role="navigation" layout="column">
<md-button>Button1</md-button>
<md-button>Button2</md-button>
</md-content>
</md-sidenav>
<md-content flex layout="column">
<md-toolbar>
<div class="md-toolbar-tools">
<button class="md-icon-button md-button" aria-label="Settings">
<md-icon md-svg-icon="images/icons/menu.svg" aria-hidden="true"></md-icon>
<div class="md-ripple-container"></div>
</button>
<md-button>Button1</md-button> <!-- how to left align this text inside a stretched button -->
<md-button>Button2</md-button>
<span flex=""></span>
<md-button>Right side button</md-button>
<button class="md-icon-button md-button" aria-label="More">
<md-icon md-svg-icon="images/icons/more_vert.svg" aria-hidden="true"></md-icon>
<div class="md-ripple-container"></div>
</button>
</div>
</md-toolbar>
<md-content flex>
Some content !!
</md-content>
</md-content>
Use empty <span> tag with a flex attribute, as shown below. You can even specify a value to the flex attribute to get a more specific location.
<div layout="row" layout-align="start center" flex>
<md-button>button 1 </md-button>
<span flex></span>
</div>
If you just want to align text inside a button, try setting the style attribute like this:
<md-button style="text-align:left">button </md-button>
You can do this if using within md-toolbar(Angular 4) Angular 6+:
Html
<mat-toolbar id="toolbar" color="primary" >
<mat-button>button 1 </mat-button>
<span class="spacing"></span>
<mat-button>button 2 </mat-button>
</mat-toolbar>
OR
<mat-toolbar id="toolbar" color="primary">
<mat-button>button 1 </mat-button>
<span style="flex: 1 1 auto;"></span>
<mat-button>button 2 </mat-button>
</mat-toolbar>
Your CSS if no styling in HTML:
.spacing {
flex: 1 1 auto;
}
Hope this helps someone.
in VueJS (nuxt-vue-material)
.md-button .md-ripple {
justify-content: unset;
}

Resources