布局策略(css加强复习)

133 阅读1分钟

1,文档流布局

块级元素(有宽和高,独占一行,大盒子)

内联元素(内容决定高度和宽度,装不下会换行)

display转换

display:block  转化块(显示)
diaplay:inline  转化行内
display:inline-block 转化行内块
display:none  隐藏

2,(position)定位布局

position:relative  相对定位(保留位置)
position:absolute  绝对定位(不保留位置)
position:fixed     固定定位(固定位置)
position:sticky    粘性定位(它允许被定位的元素表现得像相对定位一样,
直到它滚动到某个阈值点(例如,从视口顶部起10像素)为止,此后它就变得固定了)

使用方位来确定位置
top:5px
button:5px
left:5px
right:5px

子绝父相,或者子绝父绝

z-index(重叠顺序)

z-index:1
z-index:2
z-index:3
数字越大越越靠前

z-index:auto  堆叠层级和父级相同
z-index:integer  堆叠层级为0

3.(float)浮动定位


float:left  左浮
float:right  右浮
float:none 默认不浮
float:inherit 继承

clear属性 清除

clear:left  清除左浮
clear:right  清除右浮
clear:both   两边都清除

4,## (flex)弹性布局补充

##orde


orde:1 数字越小排列顺序越靠前

align-self( align-self 属性覆盖 align-items 的行为。)

button:first-child {
  align-self: flex-end;
}

4,盒子,字体,背景,伪类,边框

1边距简写.png

2边框图像简写.png

3字体简写3.png

background-image.png

broder边框.png

text-decoration.png

text标签及其属性.png

布局类型.png

布局类型2.png

浮动clear.png

块元素和行内元素互相转换.png

链接a的伪类.png

图像img.png

字体常见属性.png