CSS Selector for Adjacency

后端 未结 2 1365
耶瑟儿~
耶瑟儿~ 2020-12-06 22:46

It seems CSS is right associative, and unlike programming languages, you cannot influence this with parentheses.

I have this general structure:



        
2条回答
  •  旧巷少年郎
    2020-12-06 23:22

    You can't (yet) select your chosen

    using standard CSS selectors.

    You can, however, deploy the axe CSS selector extension library which will enable you to write selectors in your stylesheet which select parents, ancestors, previous siblings and remote elements.

    Here is an example:

    p {
    color: rgb(191, 191, 191);
    }
    
    
    .pizza < div + p {
    font-weight: bold;
    font-size: 24px;
    color: rgb(255, 0, 0);
    }

    Select me! Select me!

    Do NOT select me!


    Further Reading on axe Selectors:

    http://www.rounin.co.uk/projects/axe/axe2.html

提交回复
热议问题