0

I have the following in my css file:

md-menu-content.md-menu-bar-menu.md-dense .md-menu > .md-button:after{
    display:none;
}

And here's my HTML:

<md-menu-content class="ZZZ">
    Hello
</md-menu-content>

I have some Javascript (material design) that adds lots of stuff to the <md-menu-content> elements.

I would like to apply the above CSS to certain <md-menu-content> elements (only if they have the ZZZ class) and leave all others behaving as normal. I'm very stuck. Is this possible in CSS?

3 Answers 3

1

To apply the css that you want to all items of the ZZZ class, you should use code like this:

.ZZZ {
    //your code here
}

The . before the ZZZ signifies that it applies to items with the class ZZZ. This can be done with any class, as all you have to do is put a . (period) before the class name.

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

Comments

1

I think you are over thinking this, just use the css styling like you would any other time, and it works just fine. See fiddle: https://jsfiddle.net/pyexm7us/3/

HTML

<md-menu-content class="ZZZ">
    Hello
</md-menu-content>
<md-menu-content>
    World
</md-menu-content> 

CSS

md-menu-content{background-color: red; color: white;}
.ZZZ{background-color: blue; color: white;}

2 Comments

I was trying to apply the style display: none; to items matching md-menu-content.md-menu-bar-menu.md-dense .md-menu > .md-button:after and ZZZ How to do this?
Are they all separate elements or are they concatenated? Could you show me a snippet of the HTML? I know how to do it but it depends on how your html is laid out.
0

This is absolutely possible with CSS

To apply styling to elements with the same class simply use the prefix .

.ZZZ {
    //styling for elements with class ZZZ
}

If you want to work with id's then use the prefix #

#ZZZ {
    //styling for elements with the ID ZZZ
}

2 Comments

Eh, I want to apply the style display: none; to items matching md-menu-content.md-menu-bar-menu.md-dense .md-menu > .md-button:after AND ZZZ How to do this?
md-menu-content.ZZZ this will apply a styling to any md-menu-content with the ZZZ class. If you do md-menu-content .ZZZ (with a space) that means any element with the class ZZZ that is a child of md-menu-content

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.