Home  >  Article  >  Web Front-end  >  How to Style a Single Input Field as Partitioned Inputs?

How to Style a Single Input Field as Partitioned Inputs?

Susan Sarandon
Susan SarandonOriginal
2024-11-01 02:27:02493browse

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:

<code class="css">#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;
}</code>

HTML Implementation

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

<code class="html"><input id="partitioned" type="text" maxlength="4" /></code>

The above is the detailed content of How to Style a Single Input Field as Partitioned Inputs?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Is CSS Turing Complete?Next article:Is CSS Turing Complete?