盒子模型

53 阅读1分钟

一、盒子模型

1.1 margin

  • margin的定义: margin 属性用于定义盒子边框与周围其它盒子之间的空白区域,该空白区域称为盒子的外边距。

  • margin和padding的选择

  • margin的传递和折叠

    • 父子的传递
    • 兄弟的折叠
  • margin进行水平居中

    • 0 auto;

1.2 outline

  • 外轮廓
   -  a,input {
     -   outline: none;
    }

1.3 box-shadow

  • box-shadow: offset-x offset-y blur-radius spread-radius color inset

1.4 text-shadow

  • text-shadow: offset offset-y blur color;

1.5 box-sizing

  • content-box
  • border-box(常用)

1.6注意事项

  • width/height/margin-top/margin-bottom 对于行内非替换元素是无效的
  • padding-top/bottom,border-top/bottom对于行内非替换元素有特殊效果

1.7 水平居中

  • 行内级元素
    • text-align:center
  • 块级元素 有宽度
    • margin:0 auto;

二、背景设置

2.1 background-image

2.2 background-repeat

2.3 backgrpind-size

2.4 background-position

2.5 backgroun-attachment

2.6 background