question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

md-menu can't set max-width

See original GitHub issue

Bug

I’m trying to override the default 280px max-width of the .mat-menu-panel but it doesn’t work.

Plunker example

i’m using the latest 2.0.0-beta.3 cesium-cephalopod version, with chrome browser

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:10
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
ninanetercommented, May 11, 2017

Thank you! I’ve improved my example to better describe my problem. Now the toggle button is aligned to the right and the menu panel gets cut. If I use .cdk-overlay-container .mat-menu-panel instead of .cdk-overlay-container .mat-menu-panel.my-menu as the css selector, it works. But I want to apply it only with my specific .my-menu class.

It seems like the menu-panel is being positioned before my-menu class is added.

here is the code

4reactions
willshowellcommented, May 10, 2017

First, in your plunker, your stylesheet isn’t being included in the component. You must add the stylesheet to styleUrls.

Second, unfortunately you won’t be able to override the menu panel with your component styles due to view encapsulation. You will need to either turn view encapsulation off for this component or add the override styles to your global stylesheet.

Third, in order to actually override the styles on .mat-menu-panel, you’ll need to either use !important or increase your specificity by using multiple selectors, like .mat-menu-panel.my-overriden-menu.

https://plnkr.co/edit/iJH8g9y3wEyXQEPSiJ4C?p=preview

All that having been said, menu width should be more easily adjustable. The spec claims that it must be an increment of 56px, but the 280px max is only for mobile screens.

Read more comments on GitHub >

github_iconTop Results From Across the Web

md-menu override default max-width in Angular 2
I'm using Angular 2 , Angular Material and I am willing to display more data in a md-menu and, therefore, I need to...
Read more >
Css – md-menu override default max-width in Angular 2
I'm using Angular 2 , Angular Material and I am willing to display more data in a md-menu and, therefore, I need to...
Read more >
Max-Width - Tailwind CSS
Setting the maximum width. Set the maximum width of an element using the max-w-{size} utilities.
Read more >
Set width of menu on split-pane - Ionic Forum
Hi, I'm looking a way to set the max-width of the SplitPane The auto-size function is ... .md { ion-menu { max-width: 15%!important;...
Read more >
CSS · Bootstrap
Using a single set of .col-md-* grid classes, you can create a basic grid system that starts out stacked on mobile devices and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found