How to make textarea/input that has left/right padding 10px and will be as wide as its parent.
textarea,input{
padding:5px 10px 5px 10px;
width:100%;
}
In that case input is wider.
How to make textarea/input that has left/right padding 10px and will be as wide as its parent.
textarea,input{
padding:5px 10px 5px 10px;
width:100%;
}
In that case input is wider.
textarea{
box-sizing: border-box;
width:100%;
padding: 10px
}
Ah, the good old Box Model. Padding is ADDED to the width, so in order to achieve the desired effect, you'd have to use percentages in padding also. Try this:
textarea, input {
padding: 1% 2% 1% 2%;
width: 96%;
}
You can check my answer in related question
HTML markup:
<div class="input_wrap">
<input type="text" />
</div>
CSS:
div {
padding: 6px 10px; /* equal to negative input's margin for mimic normal `div` box-sizing */
}
input {
width: 100%; /* force to expand to container's width */
padding: 5px 10px;
border: none;
margin: 0 -10px; /* negative margin = border-width + horizontal padding */
}
Add margin property to your css code.