for
label
, the label becomes active, but there is something very attractive in a large rectangle that invites you to click on it and start typing. This is especially good for mobile apps. ( , ) . , , . , , , .
HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :
, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .

HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :

, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .
HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :
, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .

HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :

, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .

HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :

, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .

HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :

, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .
HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :
, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .

HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :

, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .
HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :
, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .

HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :

, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .

HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :

, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .

HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :

, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .
HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :
, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .

HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :

, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .
HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :
, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .

HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :

, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .

HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :

, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .

HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :

, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .

HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :

, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .

HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :

, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .

HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :

, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .

HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :

, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .

HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :

, . JavaScript: , , maman . , , , . CodePen.
( , ) . , , . , , , .

HTML:
<div> <input id="name" name="name" type="text" required> <label for="name">Your Name</label> </div>
CSS:
form > div { position: relative; } form > div > label { position: absolute; }
β2 - :focus
, for
. , , :focus
(+), , . , .
CSS:
input:focus + label { /* - */ }
, . , . : , - .
form.go-bottom label { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: 0.2s; } form.go-bottom input:focus + label top: 100%; margin-top: -16px; }
β3 - :valid
- , , , . , CSS :valid
, , . , , - . :
<input type="text" required>
, , . , :
form input:valid { background: white; }
- , .
. , :

, . JavaScript: , , maman . , , , . CodePen.
Source: https://habr.com/ru/post/216669/
All Articles