Css: changing focus to form field elements

I have a form where I used the css transition to become completely opaque using the state :hover (no JavaScript)

 #containerDiv hover:#myForm{etc} 

I would like the state to remain when the user places the cursor in any field of the form :focus , even if the mouse can no longer hover over the form. However, it is difficult for me to find the correct syntax for this to happen.

 #containerDiv #myForm ??? focus:MyFormElement{etc} 

I suspect this is only possible using JavaScript due to cascading order. However, I do not want to use JavaScript to do this so that everything is in order.

+4
source share
1 answer

Give your form and focused elements the same css values ​​as here.

 #containerDiv #myForm:hover , #containerDiv #myForm:hover MyFormElement:focus {etc} 

pseudo selectors go after the items shown above

+1
source

Source: https://habr.com/ru/post/1381185/


All Articles