Version 1.0.0 (most recent)
In the most current version of Materialize to leave the label
at the top just add in the class active
, for example <label class="active" for="first_name">Label Active</label>
Another detail important is that for the label
get on top, the input
that comes before her must be with the placeholder empty, then in the input
preceding that label
you have to leave the property empty placeholder=""
. This happens because automatically when you use placeholder
in the input
to label
related already stands at the top.
Dry code from the image above.
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<div class="row">
<form class="col s12">
<div class="row">
<div class="input-field col s6">
<input placeholder="" id="first_name" type="text" class="validate">
<label class="active" for="first_name">Label Active</label>
</div>
<div class="input-field col s6">
<input id="first_name2" type="text" class="validate">
<label for="first_name2">Labem padão</label>
</div>
<div class="input-field col s6">
<input placeholder="texto do placeholder" id="first_name2" type="text" class="validate">
<label for="first_name2">Labem padão</label>
</div>
</div>
</form>
</div>
Version 0.100.2 (old version)
From what I understand your question, if you want the label of input
always at the top without the animation you have to put in the .input-field label
the same values of .input-field label:not(.label-icon).active
.input-field label {
-webkit-transform: translateY(-14px) scale(0.8);
transform: translateY(-14px) scale(0.8);
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
}
Run the Snippet and see the example working with the Label always at the top
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.input-field label {
-webkit-transform: translateY(-14px) scale(0.8);
transform: translateY(-14px) scale(0.8);
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
}
</style>
</head>
<body>
<div class="row">
<div class="input-field col s6">
<input value="" id="first_name2" type="text" class="validate">
<label class="fixed" for="first_name2">First Name</label>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"></script>
</body>
</html>
Could you edit your question by putting excerpt of what you have already developed? so it is easier for us to help you.
– Fernando Souza
No need, but I’ll put a snippet found on the same site of Materialize css. is something that anyone who knows the tool, knows what I’m talking about
– Luiz Felipe
Exactly who knows the tool or its specific materialize put at least the link to it so we can see which classes it uses because there is probably a class that defines it in the tool itself
– Ari Santos
Always when? Apparently he’s already on top, even when the
input
is empty... It only has an effect when press F5 which is to do thelabel
rise to before theinput
, is that effect you want to remove?– hugocsl