How to render different text in HTML using embedded classes
P粉418214279
P粉418214279 2023-09-02 10:34:50
0
1
391

I want to display different text based on the category/category the code is embedded in, i.e. when the category is .category-rabbitmq.

This changes the background when the category is .category-rabbitmq.

 Read more about

This always displays a variable.

 Read more about

However, this does not work when only displaying the variable when setting the category:

 Read more about

Can you help?

P粉418214279
P粉418214279

reply all (1)
P粉232409069

Cannot nest rulesin CSS (canin SCSS). There is afirst public working draftthat allows nesting in CSS, so maybe in the future you will be able to.

So you need to do something like this:

I'm not sure how many levels the.category-rabbitmqelement has relative tothemainbody. If you know thatthemainbodyis a direct child of.category-rabbitmq, then you can be more specific and use the child combinator and optimize:>

SeeCSS Descendant CombinatorsandCSS Child Combinators.

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!