Gewusst wie: Gestapeltes Formular
Erfahren Sie, wie Sie mit CSS ein gestapeltes Formular erstellen.
Gestapeltes Formular
Ein vertikal gestapeltes Formular (bei dem Eingaben und Beschriftungen übereinander statt nebeneinander platziert werden):
So erstellen Sie ein gestapeltes Formular
Schritt 1) Fügen Sie HTML hinzu
Verwenden Sie ein <form>-Element, um die Eingabe zu verarbeiten. Mehr dazu erfahren Sie in unserem PHP -Tutorial.
Fügen Sie Eingaben (mit einem passenden Label) für jedes Feld hinzu:
Beispiel
<form action="/action_page.php">
<label for="fname">First
Name</label>
<input type="text" id="fname" name="firstname"
placeholder="Your name..">
<label for="lname">Last Name</label>
<input type="text" id="lname" name="lastname" placeholder="Your last name..">
<label for="country">Country</label>
<select id="country"
name="country">
<option value="australia">Australia</option>
<option value="canada">Canada</option>
<option value="usa">USA</option>
</select>
<input type="submit" value="Submit">
</form>
Schritt 2) CSS hinzufügen:
Beispiel
/* Style inputs */
input[type=text], select {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing:
border-box;
}
/* Style the submit
button */
input[type=submit] {
width: 100%;
background-color: #04AA6D;
color: white;
padding: 14px
20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
}
/* Add a background color to the submit button on
mouse-over */
input[type=submit]:hover {
background-color: #45a049;
}
Tipp: Besuchen Sie unser HTML-Formular-Tutorial , um mehr über HTML-Formulare zu erfahren.
Tipp: Gehen Sie zu unserem CSS-Formular-Tutorial , um mehr darüber zu erfahren, wie Sie Formularelemente gestalten können.