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

前端 未结 16 2798
有刺的猬
有刺的猬 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:37

    Is that what you had in mind?

    http://jsfiddle.net/erqrN/1/

    
    
    
    
    

    .required:after {
      content:" *";
      color: red;
    }
    
    

    See https://developer.mozilla.org/en-US/docs/Web/CSS/pseudo-elements

提交回复
热议问题