Reputation: 134
So what I'm trying to do, is to put an input-field over a label and change the background-color of the input-field on focus. So that the bgColor covers the text of the label.
Here is what it looks like:
<div class="d-faq-field">
<label class="i-faq-lastname-label" for="i-faq-lastname">Nachname</label>
<input id="i-faq-lastname" type="text" name="lastname">
</div>
I've put both input field and label in a div so that everythings responsive and the div's can float beside each other.
Also, have a look at the jsFiddle. There is a div on the top where it already works but I cannot seem to reconstruct it properly.
Upvotes: 0
Views: 77
Reputation: 2204
I don't know if I understood, but why not use the placeholder attribute?
<textarea id="i-question2" required="required" type="search" name="question" placeholder="Gib hier deine Frage ein"></textarea>
Upvotes: 0
Reputation: 123387
if I well understood try simply
input:focus {
position: relative;
z-index: 1;
}
so, when the input is focused it will cover the label. Anyway you will see the label again when the input loses its focus.
Probably you could obtain the right behaviour simply using the placeholder
attribute
Upvotes: 1