Reputation:
I have a web page set at a certain restraint for responsive viewing based on screen width. Though, I'm running into an issue where I have a form input set a width of width:100%
and padding-left:20px
. The result displays the input field width scaling beyond the width of the body of the webpage by 20px because of the padding.
Input code:
.field {
outline:0;
width:100%;
height:50px;
padding-left:10px;
float:left;
border: 1px solid #d3d4d5;
border-right-color: #c2c7ca;
border-left-color:#c2c7ca;
color:#3a444f;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 5px;
position: relative;
z-index: 0;
-webkit-background-clip: padding-box;
font-size:16px;
}
How can I get that extra space at the end of the input field to restrain to the proper width?
Upvotes: 2
Views: 481
Reputation: 41100
You don't need to add any extra space. You can simply use:
input {
box-sizing: border-box;
width: 100%;
}
With the border-box
option the width setting includes padding and border.
Upvotes: 2