css查漏补缺之十三-box model recap
/ / 点击 / 阅读耗时 2 分钟overflow
overflow的默认值是visible。
background
默认情况下,backgrounds延伸到border的外边延。
使用background-clip属性可以设置backgrounds仅延伸到内容的边缘。
background-clip可以设置的值有:
border-boxpadding-boxcontent-boxtext
设置在文本上的时候,可以这样设置:
1 | background-clip: text; |
outline
outline不是盒模型的一部分,看起来像是border,但实质是画在盒子的上方,同时也不会改变盒子的尺寸(具体来讲是画在边框外,在外边距内)。
advanced box properties
- setting width and height constraints
一个常见的用法:
1 | .container { |
使用margin: 0 auto;来给inner盒子居中在parent中时,需要设置本盒子的宽度,这个宽度设置成 百分比 也是有效果的。auto的意思是让容器左右两侧的外边距分享可用的空间,以实现居中的效果。
- changing the box model completely
盒子的总宽 = width + padding-left + padding-right + border-right + border-left
全文完。