CSS列表样式、盒子模式、float的使用、position的使用

来源:互联网 发布:天龙八部淘宝抢号行吗 编辑:程序博客网 时间:2024/06/06 01:30

列表样式

1、有序和无序列表/*ul li{list-style-type: square;}*/
 /* ul li{list-style-type: decimal;}*/
 2、设置列表标记图片 ul li{list-style-image: url(img/html1.jpg);}
3、是否环绕文字.ul li{list-style-position:inside;}或者outside
4、简单写法  list-style: outside square

盒子模型

1、width:长度、百分百、auto 、max-width、min-width:
2、height:长度、百分百、auto 、max-height、min-height:
3、块级元素和替换元素可以用width和height 
4、border:.one{border-top-width: 10px;border-top-color: red;border-top-style: solid;}简写模式:border
5、padding:padding: 20px;或者padding-top: 20px;
6、margin (外边距)元素和元素之间的 ,auto为居中显示 ,垂直方向上的像素是外边距是合拼的
7、diaplay的inline改成内联元素,block改成块级元素  display: inline-block呈现出来的是inline同时拥有两个属性 ,不显示是none

float的使用

left/right/inherit(继承父类);
2、副作用是(使父类尺寸为0;父类兄弟类的元素在float傍边)
3、解决办法
a、给父元素添加高度
b、通过clear解决(推荐)
c、 在父类添加right;overflow: hidden;zoom:1;
b、在父类添加float ,

position的使用

1、relative属性;写那个方向就往那个反方向移动。后定位的覆盖先定位的
2、absolute绝对定位,写那个方向,就离浏览器那个反方向多少距离(以窗口为主)
3、fixed 固定定位 用于对联广告等 ,不受于父元素
4、inherit:继承属性,父元素是什么定位属性,那么子元素就是什么属性

层级的排序z-index
1、服务于带有定位属性的元素
2、子元素会大于比父元素层级小的元素