Home > Article > Web Front-end > 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!