There's a simple solution for this, just add this to your CSS declaration:
box-sizing: border-box;
The reason for horizontal scrollbar appears is that padding and border is by default added to whatever width you give to your element. By setting it explicitly to border-box
, the padding and border are included in that width value.
This property is supported in IE8+, FireFox 19+ (by using -moz-box-sizing
) and iOS Safari and Android (by using -webkit-box-sizing
)
Also, I strongly suggest using shorthand css, as follows:
.test {
BOX-SIZING: border-box;
WIDTH: 100%;
HEIGHT: 100%;
PADDING: 10px 0 10px 10px;
BORDER: #7F9DB9 1px solid;
BACKGROUND-COLOR: #ffffff;
}