I am trying to automatically adjust the length of the hr element to the length of the input element using CSS.
Also an animation that is executed when the focus is on the input.
I saw this solution on stackoverflow for the h2 element: How to do it with h2 element
Code:
h2{
font-size:50px;
padding:0 25%;
text-align:center;
}
h2 hr{ width:100%;height:10px;background:#000;}
<h2>
This is a very big title
<hr />
</h2>
I have tried it with the input element, but it does not work.
My Code:
hr.underline {width: 0%;}
input.input:focus hr.underline{
left:0;
width:100%;
height:2px;
background-color:#17e13f;
border:none;
margin-top:5px;
margin-left:0;
margin-bottom:0px;
}
<div>
<label for="1">Eingabe</label>
<input class="input" type="text" id="1">
<hr class="underline">
</input>
</div>
But this wont work. Does anyone know how, or is there a better way to do that?