Using :focus to style outer div?

后端 未结 10 731
礼貌的吻别
礼貌的吻别 2020-12-02 18:24

When I begin writing text in the textarea, I want the outer div, with a class box, to have it\'s border turned solid instead of dashed, but somehow the :focus doesn\'t apply

10条回答
  •  庸人自扰
    2020-12-02 18:47

    As per the spec:

    The :focus pseudo-class applies while an element has the focus (accepts keyboard events or other forms of text input).

    The

    does not accept input, so it cannot have :focus. Furthermore, CSS does not allow you to set styles on an element based on targeting its descendants. So you can't really do this unless you are willing to use JavaScript.

提交回复
热议问题