.wrapper {
position: relative;
width: 300px;
height: 300px;
background-color: blue;
}
div, input{
position: absolute;
left: 20px;
right: 20px;
height: 20px;
}
div {
top: 0;
background-color: red;
}
input {
top: 20px;
background-color: orange;
width: calc(100% - 40px); /* does not react as a div, need to manually specify width */
border: 0; /* remove default border */
padding: 0; /* remove default padding */
}
<div class="wrapper">
<div></div>
<input>
</div>
Problem :
Is there a simple way to let the input grow from left to right like the div in my example do? Why does the input tag (and also button) not work like a div in this case (is the missing </input> the problem for tags like this)?
Sry, was too fast, thx, but it doesnt solve the problem.
Comment posted by Warden330
input and button elements have a standard-format other than divs. That makes them behave differently too. You will have to add a width manually to such elements
Comment posted by Pepe
Ah, ok, “width: calc” do the trick, good to know that this is working for elements like this – thx for help!