Zum Hauptinhalt springen
VelinStyle v1.2.0
⌂ Home
  1. Docs
  2. Formulare
  3. Schwebende Labels

Schwebende Labels 1.2.0

Erstelle animierte Formular-Labels, die mit .velin-float-label über der Eingabe schweben, wenn sie fokussiert oder gefüllt ist. English: Floating Labels

Reifegrad: .velin-float-label ist in 1.2.0 stabiles CSS. Bevorzuge statische Labels, wenn Klarheit wichtiger ist als Dichte.

Wann verwenden

Wann nicht

Einfaches Beispiel

Wickle Eingabe und Label in .velin-float-label. Die Eingabe muss vor dem Label stehen, und ein placeholder-Attribut ist erforderlich (es darf ein Leerzeichen sein).

<div class="velin-float-label">
  <input type="email" class="velin-input" id="email" placeholder=" ">
  <label class="velin-label" for="email">Email address</label>
</div>

<div class="velin-float-label">
  <input type="password" class="velin-input" id="password" placeholder=" ">
  <label class="velin-label" for="password">Password</label>
</div>

Textarea

Schwebende Labels also work with <textarea> elements.

<div class="velin-float-label">
  <textarea class="velin-input" id="msg" placeholder=" " rows="3"></textarea>
  <label class="velin-label" for="msg">Your message</label>
</div>

Auswahl

Nutze dies mit .velin-select für Selects mit schwebendem Label.

<div class="velin-float-label">
  <select class="velin-select" id="category">
    <option selected>Choose…</option>
    <option value="1">Option 1</option>
  </select>
  <label class="velin-label" for="category">Category</label>
</div>

Barrierefreiheit