I am using angular material sidenav for some application settings functionality to achieve something like we have in Google.
The difference is I am calling this sidenav from another component and wrapping the router too so that it should open below the application Header.
<mat-sidenav-container class="main-sidenav">
<app-sidenav></app-sidenav>
<router-outlet></router-outlet>
</mat-sidenav-container>
The problem is when I open the sidenav It does not disable the background. It should automatically implement the backdrop style. Is there any way I can explicitly provide some style for the same or should we consider some different component? Please suggest. Below is the sample stackblitz example for the same scenario
Stackblitz link
Set the hasBackdrop flag to true in your html:
<mat-sidenav-container class="main-sidenav" hasBackdrop="true">
<app-sidenav></app-sidenav>
<router-outlet></router-outlet>
</mat-sidenav-container>
Per Material doc of sidenav:
Using your stackblitz, I have confirmed the backdrop renders by inspecting the elements:
But you are not seeing the dark shadow, because of missing css. To fix this, add following in your styles.css file.
.mat-drawer-backdrop {
background-color: rgba(0, 0, 0, 0.6);
}
Also, to make the sidenav appear like the screenshot in your question, you need to add some css properties in sidenav class.
.sidenav {
margin-top: 35px;
margin-left: 25px;
display: block;
width: 200px;
height: 100%;
position: fixed;
background: #FFF;
}
Result:
Stackblitz Demo
Related
Height is not added properly in the modal body when the modal is opened as a separate component using ng-bootstrap.
Issue exist on below stackblitz link
https://stackblitz.com/edit/angular-xwqusl?file=src%2Fapp%2Fmodal-component.ts
Working Example:
It was working as expected without a separate component.
https://stackblitz.com/edit/angular-tfpf81?file=src%2Fapp%2Fmodal-options.ts,src%2Fapp%2Fmodal-options.html
Does anyone know about this issue?
Thank you for the stackblitz, I think the issue is due to view encapsulation - being set as none, so css didn't get applied.
In Angular usually the html element with the component selector ngbd-modal-content will not take the height of the parent, we need to manually adjust it with css, its a pain point of angular!
// encapsulation: ViewEncapsulation.None, // <- remove this
styles: [
`
:host {
display: flex;
flex-direction: column;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
border: solid 3px yellow; /* for debugging purposes */
}
`,
],
forked stackblitz
I would like to remove the following from the HOMPE PAGE ONLY!
I have access to page editor but not sure what to insert in the CSS editor on that page.
I want to remove the below:
<div class="fs_img_header header_video_fs_view" style="width: 1028px; height: 789px;"><div class="stat_img_cont" style="background-image: url();background-size: cover;background-position: center center;"></div></div>
.fs_img_header, .header_video_fs_view, .stat_img_cont {
display: none;
}
if you're using Wordpress and the css has no effect:
.fs_img_header, .header_video_fs_view, .stat_img_cont {
display: none !important;
}
To display it only on the homepage use following plugin (easy-way):
https://de.wordpress.org/plugins/css-javascript-toolbox/
With this plugin you can choose where it displays your custom css (in this case the homepage).
Let me know if this helps.
We have a weird issue with our SVG icons in our mobile menu. They appear very big in the mobile version although they are set at 1.6em.
Go here, open the hamburger menu and click on the "Shop Now" Dropdown, you will see the size of the icons
We tried the following CSS in the WordPress Customizer but it seems like it's not that class, and that's weird because using the Chrome Developer Tools if we modify that class it seems to change.
.sidr-class-icon sidr-class-before sidr-class-svg {
max-width: 15%;
}
Note: Using !important tag also doesn't work.
The class of this image is class='sidr-class-icon sidr-class-before sidr-class-svg'. So to select it in css you need to use:
.sidr-class-icon.sidr-class-before.sidr-class-svg { ... }
And not:
.sidr-class-icon sidr-class-before sidr-class-svg { ... }
.sidr-class-icon.sidr-class-before.sidr-class-svg {
max-width: 15%;
border: solid red 3px;
}
<img src="https://www.safe-company.com/wp-content/uploads/2020/08/bmeeting.svg" class="sidr-class-icon sidr-class-before sidr-class-svg" aria-hidden="true">
Try setting height and width attributes for your img tags.
Today I have this code, basically when I click on Details button it opens a mat-menu but somehow I can not modify padding or width values of the menu :
<div id="box-upload" [hidden]="hiddenBoxUpload" *ngIf="filesExist">
<button mat-raised-button color="primary" [matMenuTriggerFor]="listFiles">Details</button>
<mat-menu class="filesList" #listFiles="matMenu">
<div *ngFor="let key of listkey">
<div *ngIf="detailsExist">
<!-- some stuff like mat-progress-bar and span>
</div>
</div>
</mat-menu>
</div>
css code :
.filesList {
width: auto;
padding: 15px;
}
What are the ways to change default padding and width of a mat-menu ?
You can either put the following in your global styles.css
.mat-menu-content {
padding: 30px;
}
Or you can use ::ng-deep in your component style sheet
::ng-deep .mat-menu-content {
padding: 30px;
}
Either solution above will allow you to modify the default padding of
all mat-menu's in your project.
Per this SO answer, until an alternative or replacement is provided for ::ng-deep the recommendation is to continue using it...
What to use in place of ::ng-deep
If you want to control only a specific mat-menu you will need to use your custom class in your CSS selectors
::ng-deep .filesList .mat-menu-content{
padding: 30px;
}
Revision
To adjust the width of the mat-menu without creating a scroll bar you need adjust the width of the root container cdk-overlay-pane... by adjusting the width of the mat-menu-content you are making that container wider than the root container, and because it is within the root container cdk-overlay-pane it creates a scroll bar by design. Try the following to widen the mat-menu without creating a scroll bar.
::ng-deep .cdk-overlay-pane .filesList{
min-width:600px;
}
I'm new Angular, CSS and Html.
I have used MatTabsModule(import { MatTabsModule } from '#angular/material/tabs';) to create tabs but I'm able to adjust/change height, background etc. In short I'm not able to override default properties of MatTabsModule's classes. Please help me.
Below is my CSS and Html code. I hope Typescript code is not needed.
HTML: -
<mat-card>
<mat-card-content>
<mat-tab-group class="tab-group" dynamicHeight>
<mat-tab *ngFor="let obj of tags">
<ng-template mat-tab-label>{{ obj.name }}</ng-template>
<div class="tab-content">
{{ obj.name }}
</div>
</mat-tab>
</mat-tab-group>
</mat-card-content>
CSS: -
.tab-group {
border: 1px solid #e8e8e8;
margin-bottom: 30px;
.unicorn-dark-theme & {
border-color: #464646;
}
}
.tab-content {
padding: 16px;
}
mat-card{
padding: 0px;
}
.mat-tab-label .mat-ripple {
min-width: 0;
height: 30px;
}
I'm not able to change height width background colour of these tabs.. :(
You cannot access the styles of child components from your css-file as the ViewEncapsulation.Emulated prevents styles from leaking to the rest of the app (as it should, don't change it).
If you use the ng-deep-selector like this: :host ::ng-deep mat-tab { ... } you can override default material styles that cannot be configured in any other way. I say that because making css leak from a component is considered a bad practice and if possible you should use #Input to pass on styles.
By the way, the :host is there so the styles leak only to this components children and not to the rest of the app
To override default style of angular material elements you need to prefix ::ng-deep in CSS style.
This is how you can control height and width of tabs
::ng-deep .mat-tab-label{
height: 27px !important;
min-height: 0px!important;
margin: 3px!important;
}