05.绝对定位元素的布局1
水平布局
left+margin-left+border-left+padding-left+width+padding-right+border-right+margin-right+right
=包含块的内容区的宽度
- 当我们开启了绝对定位后: 水平方向的布局等式就需要添加left和right两个值 此时规则和之前一样,只是多添加了两个值: 当发生过度约束: 如果9个值中没有auto,则自动调整right值以使等式满足 如果有auto,则自动调整auto的值以使等式满足
- 可设置auto的值 margin width left right
- 因为 left 和 right 的值默认是auto,所以如果不知道left和right, 那么等式不满足时,会自动调整这两个值。(其实此时只会调整right) 垂直方向布局也必须要满足 top+margin-top+border-top+padding-top+height+padding-bottom+border-bottom+margin-bottom+bottom =包含块的高度 ???????规则和水平方向完全一致
举例:如果不理解,把等式写出来就清楚了。
- 当我们开启了绝对定位后: 水平方向的布局等式就需要添加left和right两个值 此时规则和之前一样,只是多添加了两个值: 当发生过度约束: 如果9个值中没有auto,则自动调整right值以使等式满足 如果有auto,则自动调整auto的值以使等式满足
- 可设置auto的值 margin width left right
- 因为 left 和 right 的值默认是auto,所以如果不知道left和right, 那么等式不满足时,会自动调整这两个值。(其实此时只会调整right) 垂直方向布局也必须要满足 top+margin-top+border-top+padding-top+height+padding-bottom+border-bottom+margin-bottom+bottom =包含块的高度 ???????规则和水平方向完全一致
举例:如果不理解,把等式写出来就清楚了。
Document
应用:
margin-left:auto;
margin-right:auto;
left:0;
right:0;
margin-top:auto;
margin-bottom:auto;
top:0;
bottom:0;
即:
margin:auto;
left:0;
right:0;
top:0;
bottom:0;