Use CSS to automatically add 'required field' asterisk to form inputs

前端 未结 16 2797
有刺的猬
有刺的猬 2020-11-28 19:10

What is a good way to overcome the unfortunate fact that this code will not work as desired:

16条回答
  •  无人及你
    2020-11-28 19:36

    What you need is :required selector - it will select all fields with 'required' attribute (so no need to add any additional classes). Then - style inputs according to your needs. You can use ':after' selector and add asterisk in the way suggested among other answers

提交回复
热议问题