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

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

    input[required], select[required] {
        background-image: url('/img/star.png');
        background-repeat: no-repeat;
        background-position-x: right;
    }
    

    Image has some 20px space on the right not to overlap with select dropdown arrow

    enter image description here

    And it looks like this: enter image description here

提交回复
热议问题