0

Here is the screenshot from chrome dev tools. Here I want to override .ui-menu class and want to increase its with to "20em". enter image description here

Here is what I am trying to override it :

.menu.ui-menu{

    width:20em;
}

I know my css is loading after the base css. Why its not taking the css supplied in custom css class?

UPDATE None of the suggestions provided below worked for me. I have added a div and provided id to div "menu". Now when I use following css , it works :

#menu  {

    width:20em;
    background-color: yellow;
}

Here is the screenshot from console: enter image description here

Still unable to increase width of menu that has class "ui-menu". Can someone please help in identifying the selector for "ui-menu" ?

3 Answers 3

2

You just need a space between .menu and .ui-menu, like this:

.menu .ui-menu {
    width:20em;
}

.menu.ui-menu is looking for an element with both the menu and ui-menu classes, whereas .menu .ui-menu is looking for an element with class ui-menu that is a child of menu.

Sign up to request clarification or add additional context in comments.

Comments

1

I found answer to this problem. I am trying to set the css in angular 4 application and all styles are encapsulated by default. to fix this , use following code in component class:

import { ViewEncapsulation } from '@angular/core';

@Component({

   encapsulation: ViewEncapsulation.None

})

Once this is done, all css overriding will work as expected.

Comments

0

The ui-menu class is on a div, so you could write:

div.ui-menu {
    width:20em;
}

or

.ui-menu {
   width:20em !important;
}

or

body .ui-menu{
width:20em;
}

or something else, all solutions are higher weighted than the ".ui-menu" style as there already is at the moment

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.