Styling input password in HTML

前端 未结 6 888
终归单人心
终归单人心 2020-12-25 14:24

I have an input type password that only allow a six-digit number like this:

6条回答
  •  臣服心动
    2020-12-25 14:36

    To Solve the problem:

    • Place ::after on fieldset instead of input box or add an element.
    • Set content value using underscores, and position the elements.
    • Add letter-spacing and width to input box, and set :focus as outline: none to delete the blue box.

    fieldset {
      color: #555;
      font-family: sans-serif;
      border: none;
      position: relative;
    }
    
    fieldset > * {
      display: block;
    }
    
    fieldset::after {
      content: "___  ___  ___  ___  ___  ___";
      display: block;
      position: absolute;
      top: 35px;
      white-space: pre;
    }
    
    label {
      font-size: 14px;
      margin-bottom: 6px;
    }
    
    input#password-input {
      position: relative;
      font-size: 16px;
      z-index: 2;
      border: none;
      background: transparent;
      width: 300px;
      text-indent: 9px;
      letter-spacing: 25.6px;
      font-family: Courier;
    }
    
    input#password-input:focus {
      outline: none;
    }
    
    span.hint {
      margin-top: 8px;
      font-size: 12px;
      font-style: italic;
    }
    
    span.hint::before {
      content: "* ";
    }
    New pin must be 6 digit number only

提交回复
热议问题