I want to make PrimeFaces like outputlabel and inputtext i like Google user input. When I do the following example for html, I don't encounter any problems, it just doesn't work when I want to implement it for PrimeFaces. How can I solve this problem?
The problem appears more clearly below
Although the first inputtext is not yet focus
But the second inputtext title appears in the middle
This is where I'm having trouble.
Thank you in advance for your help.
body {
font-family: sans-serif;
}
.label-before, .field input:valid + label::before, .field input:focus + label::before {
line-height: 20px;
font-size: 12px;
top: -10px;
background: #fff;
padding: 0 6px;
left: 9px;
}
.container {
width: 80%;
margin: 30px 10%;
}
.field {
position: relative;
margin-bottom: 15px;
}
.field label::before {
content: attr(title);
position: absolute;
top: 0;
left: 15px;
line-height: 40px;
font-size: 14px;
color: #777;
transition: 300ms all;
}
.field input {
width: 100%;
line-height: 40px;
padding: 0 15px;
box-sizing: border-box;
font-size: 14px;
color: #222;
border: 1px solid #ccc;
border-radius: 3px;
}
.field input:focus {
outline: 0;
border-color: blue;
}
.field input:valid + label::before {
content: attr(data-title);
}
.field input:focus + label::before {
color: blue;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<div class="container">
<div class="field">
<input type="password" required autocomplete="off" id="password">
<label for="password" title="Şifrenizi girin" data-title="Şifre"></label>
</div>
</div>