<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/1.8.11/tailwind.min.css" crossorigin="anonymous"/>
<div class="background" id="background"></div>
<div class="bg-white rounded p-10 text-center shadow-md">
  <h1 class="text-3xl">密码强度看图片清晰度</h1>
  <p class="text-sm text-gray-700">密码强度越强,图片越清晰,不信,你改一下试试</p>
  <div class="my-4 text-left">
    <label for="email" class="text-gray-900">邮箱:</label>
    <input  type="text"  class="border block w-full p-2 mt-2 rounded"  id="email"  placeholder="你的邮箱" />
  </div>

  <div class="my-4 text-left">
    <label for="email" class="text-gray-900">密码:</label>
    <input   type="password"  class="border block w-full p-2 mt-2 rounded"  id="password"  placeholder="输入你的密码" />
  </div>

  <button class="bg-black text-white py-2 mt-4 inline-block w-full rounded" type="submit" >
    提交
  </button>
</div>

* {
  box-sizing: border-box;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  overflow: hidden;
  margin: 0;
}

.background {
  background: url('https://ts1.cn.mm.bing.net/th/id/R-C.3324c916f2ef8a914a30a8a4d3131734?rik=DJWAjiAHtUbfpQ&riu=http%3a%2f%2fimg.mm4000.com%2ffile%2f9%2f49%2f256ae4988b.jpg&ehk=juxYR8KUKG1MbFea%2fp5iwzJ%2bH2JI8OmKcHC79%2bI09sc%3d&risl=&pid=ImgRaw&r=0')
    no-repeat center center/cover;
  position: absolute;
  top: -20px;
  bottom: -20px;
  left: -20px;
  right: -20px;
  z-index: -1;
  filter: blur(20px);
}

const password = document.getElementById('password')
const background = document.getElementById('background')

password.addEventListener('input', (e) => {
  const input = e.target.value
  const length = input.length
  const blurValue = 20 - length * 2
  background.style.filter = `blur(${blurValue}px)`
})
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.