How to add padding or border to a DIV and keep width and height?

后端 未结 5 1336
半阙折子戏
半阙折子戏 2020-12-28 18:42

Is there some way to keep a set width/height for a DIV, and pad the content without the DIV growing? See example below. I want all the boxes to be exactly 140x140.

H

5条回答
  •  自闭症患者
    2020-12-28 19:11

    Yes the solution to your problem is box-sizing:border-box; ( http://css-tricks.com/box-sizing/ , http://paulirish.com/wp-content/uploads/2011/gplus-boxsizing.html ) (works in IE8+ and all modern browsers)

提交回复
热议问题