css
标签上设置style属性
background=color:red;height:20px
编写css样式
1.标签的style属性
2.写在head里面,style属性
#i1{background=color:red;height:20px} id=“i1”
.cl{background=color:red;height:20px} class=“c1”
div{…} div选择器
#i1{…} id=“i1” id选择器
.c1{…} class=“c1” class选择器
优先级:标签上的style优先,然后就近原则
注意:css样式也可以写在单独文件中,引用
3.关联层级选择器(空格) span div{} span下的div段
4.组合选择器(逗号,) span,div,.c1{} 多个选择
5.属性选择器 input[type=“text”]{…}
注释/* */
6边框
asadd
border 边框 solid实线 dotted虚线 颜色red
border-left 左边 top上边
5
height 高度 百分比
weidth 宽度,像素 百分比
text-align:ceter 水平方向居中
line-height:height 垂直方向根据标签高度居住
color 字体颜色
font-size 字体大小
font-weight 字体加粗
6 float
让标签飘起了,快级标签可进行堆叠
style=“clear:both;” 父包子
style=“display:inline;” 变成行内标签
style=“display:block;” 变成块级标签
style="margin: 0 auto; 一行铺满无边界
7 display
display:none; 让标签消失
display:inline;
display:block;
display:inline-block;
具有inline,默认自己有多少占多少
具有block设置高度 宽度 padding margin
行内标签:无法设置高度 宽度 padding margin
块级标签:设置高度 宽度 padding margin
8 paading margin(0,auto)
paading 边距
CSS补充
position:fixed 固定位置
top bottom left right
relative + absolute 相对定位