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

How to Style a Single Input Field as Partitioned Inputs?

Susan Sarandon
Release: 2024-11-01 02:27:02
Original
519 people have browsed it

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>
Copy after login

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>
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template