- index.html
- style.css
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<title>Text input field, step 2</title>
<meta charset="utf-8">
<link rel="stylesheet" href="material.css">
<link rel="stylesheet" href="style.css">
</head>
<body class="purple-theme">
<section class="card">
<h1 class="question"><span>What was the very first web browser was called?</span></h1>
<form class="answers" action="https://echo.htmlacademy.ru/courses" method="post">
<button class="fab" type="submit"></button>
<div>
<input type="text" required>
<div class="label-box">
<label>Word in English</label>
</div>
</div>
</form>
</section>
</body>
</html>
CSS
.label-box {
position: relative;
width: 270px;
}
input {
box-sizing: border-box;
padding: 5px;
width: 270px;
border: none;
border-bottom: 1px solid #757575;
font-size: 18px;
}
label {
position: absolute;
top: -36px;
color: #757575;
font-size: 18px;
pointer-events: none;
}
input:focus ~ .label-box label,
input:valid ~ .label-box label {
}
You’ve gone to a different page
Goalscompleted
0
- When the input field is in focus or valid, set the
label
to have a font size of14px
and atranslateY(-20px)
transform. - And then add a transition that is
0.2s
long for all of the properties to the label for the general CSS rule.
Click inside and outside of the input field in order to test the result.
Comments