Is there such a thing as an “all inclusive sibling” CSS selector?

后端 未结 4 1861
梦如初夏
梦如初夏 2020-12-01 15:55

My HTML:

Doggies

Froggies

Cupcakes

<
4条回答
  •  情话喂你
    2020-12-01 16:30

    My scenario was a little different but I wanted to select siblings of an input element to display one while it was active and another if it was left invalid.

    My html was like this and I was unable to select the invalid text.

    
    

    I was able to get around it by embedding the siblings in an adjacent one and using child selectors on that.

    
    
    .help-text, .invalid-text { visibility:hidden; } .input:active +.messages > .help-text { visibility:visible; } .input.invalid:visited +.messages > .invalid-text { visibility:visible; }

    And it worked.

提交回复
热议问题