I'm trying to make label
simulate a fixed placeholder.
The biggest difficulty is to change the properties of label
when input
gets focus
, and input
fill in the rest of the space automatically.
I tried to use the same technique as float:left
with overflow:hidden
, but it did not work.
Would you like to do this using only CSS?
HTML
<article>
<form>
<label>Qualquer nome para qualquer tamanho</label>
<input>
</form>
</article>
CSS
*{
margin: 0;
padding: 0;
}
body{
font-family: arial;
}
article{
margin: 5% 0 0 4%;
width: 50%;
}
label{
float: left;
padding: 2%;
background: #ccc;
line-heigt: 0;
font-size: 1em;
border-radius-right: 3px;
}
form{
width: 100%;
}
input{
display: block;
padding: 2%;
overflow: hidden;
border: 0;
background: #ccc;
font-family: arial;
font-size: 1em;
outline: none;
}
input:focus{
background: #999;
}