Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing style of overlay container

I use a git project for a virtual keyboard (https://ngx-material-keyboard.github.io/demo/). And I have some issues to get it running on a small device with 450*250 pixel.

At the end I found the necessary changes in the css if I modify it directly at the web browser with dev tools.

Now I have to find the right position to change the sources.

There will be used the overlay component from angular2-material to visualize the keyboard.

If I comment out the position in the cdk-overlay-container, it works:

.cdk-overlay-container {
/* position: fixed; */
z-index: 1000;

}

But I cant overwrite these from my angular application. Any suggestions?

Screenshot of changes

like image 747
user1025633 Avatar asked Aug 10 '17 09:08

user1025633


People also ask

What is an overlay container?

The overlay container The OverlayContainer provides a handle to the container element in which all individual overlay elements are rendered. By default, the overlay container is appended directly to the document body so that an overlay is never clipped by an overflow: hidden parent.

What is CdkConnectedOverlay?

CdkConnectedOverlay. Directive to facilitate declarative creation of an Overlay using a FlexibleConnectedPositionStrategy.

What is CDK Global Scrollblock?

cdk-global-scrollblock css class. This class is added to the html tag when the block strategy is used. It is used to block the scroll of the content behind the dialog, especially on mobile devices (iOS) - that's why position: fixed; is used.


1 Answers

UPDATED ANSWER

From the official documentation:

Styling overlay components

Overlay-based components have a panelClass property (or similar) that can be used to target the overlay pane.

You can override the default dialog container styles by adding a css class in your global styles.css. For example:

.custom-dialog-container .mat-dialog-container {
    /* add your styles */
}

After that, you'll need to providies you css class as a panelClass parameter to your dialog:

this.dialog.open(MyDialogComponent, { panelClass: 'custom-dialog-container' })

Read this official documentation for more information.


ORIGINAL ANSWER

Use ::ng-deep in your component.css to override the default styles.

::ng-deep .cdk-overlay-container {
    /* Do you changes here */
    position: fixed; 
    z-index: 1000;
}
like image 91
Faisal Avatar answered Sep 20 '22 02:09

Faisal