toggling styles on label (active/focus) for input field with css only

后端 未结 7 1489
无人共我
无人共我 2020-12-16 15:28

Wondering whether if there is a css-only way to perform to toggle styles on the corresponding label on input\'s focus. So far I have:

    $(         


        
7条回答
  •  鱼传尺愫
    2020-12-16 15:45

    There is no selector to match a preceding element... This matches a label immediately followed by an input tag.

    input:focus + label {
        color: red;
    }
    

提交回复
热议问题