"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Style a Single Input Field as Partitioned Inputs?

How to Style a Single Input Field as Partitioned Inputs?

Published on 2024-11-05
Browse:157

How to Style a Single Input Field as Partitioned Inputs?

Styling an Input Field as Partitioned Inputs

Numerous methods exist for creating a series of partitioned input fields. One method utilizes "letter-spacing" to separate characters within a single input field. Additionally, "background-image" and "border-bottom" styling can further enhance the illusion of multiple input fields.

CSS Snippet

The following CSS code demonstrates how to create the desired effect:

#partitioned {
  padding-left: 15px;
  letter-spacing: 42px;
  border: 0;
  background-image: linear-gradient(to left, black 70%, rgba(255, 255, 255, 0) 0%);
  background-position: bottom;
  background-size: 50px 1px;
  background-repeat: repeat-x;
  background-position-x: 35px;
  width: 220px;
  outline: none;
}

HTML Implementation

To use this CSS, simply add the following HTML code to your page:

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3