去除input自动填充时的背景色

我想应该做过登录的页面的同学都遇到过这样的问题,input的自动填充功能会带有背景色,这样会影响美观,如下图
去除input自动填充时的背景色_第1张图片
要想去掉这个背景色有两种方法:
1.给input设置属性autocomplete=“off”,意为关闭自动填充,不记录之前输入过的值。完全可以解决背景色的问题,但是没有自动填充功能体验相对来说不是很友好
2.通过css样式:

<style lang="less">
  input:-webkit-autofill {
    box-shadow:0 0 0 1000px white inset !important;
  }
  input:-internal-autofill-previewed,
    input:-internal-autofill-selected {
    -webkit-text-fill-color: #333 !important;
    transition: background-color 5000s ease-in-out 0s !important;
  }
</style>

这样设置之后就再也不会有背景色了。万岁

你可能感兴趣的:(记录)