You could add box-sizing:border-box
to the container element, to be able to specify a width and height that don't vary when you add padding and/or border to the element.
See here (MDN) for specifications.
Update (copied comment to answer)
Right now, the value border-box
is supported in all major browsers, according to MDN Specs
Some browsers of course requires proper prefix i.e. -webkit
and -moz
as you can clearly see here
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…