Detecting Browser Autofill

前端 未结 29 1458
天涯浪人
天涯浪人 2020-11-22 06:15

How do you tell if a browser has auto filled a text-box? Especially with username & password boxes that autofill around page load.

My first question is when does

29条回答
  •  悲&欢浪女
    2020-11-22 06:50

    Here is CSS solution taken from Klarna UI team. See their nice implementation here resource

    Works fine for me.

    input:-webkit-autofill {
      animation-name: onAutoFillStart;
      transition: background-color 50000s ease-in-out 0s;
    }
    input:not(:-webkit-autofill) {
      animation-name: onAutoFillCancel;
    }
    

提交回复
热议问题