四、选择器初级和背景

2017-08-18  本文已影响0人  东东丶酱

1、选择器

1.通配符选择器 *{margin:0;padding:0;}
2.元素选择器 div{width:;height:;}
3.class选择器 .nav{width:;height:;}
4.id选择器 #banner{width:;height:;}
5.后代选择器 div ul li p{background:;}

命名规范

HTML命名规范:

    以小写字母开头
    不能以数字开头
    见名知意

行业内命名规范:

    可以加 - 或 _
    驼峰命名

2、背景样式

(1)背景颜色

background-color:

    十六进制值:#fff
    英文单词:red     blue     yellow
    rgb / rgba(css3)

(2)背景图片:

background-image:url(‘1.jpg’)

    url(‘’) :   路径
    none :  不使用背景图片

(3)背景图片的重复方式:

background-repeat:

    no-repeat       不重复
    repeat-x        水平方向重复
    repeat-y        竖直方向重复
    repeat      默认值

(4)背景图片的位置:

background-position:X Y

1.关键词写法 top/bottom/left/right/center  第一个值水平,第二个值垂直
2.如果只出现一个关键词,那么另一个对应的就是center
3.百分数值:background-position:20p% 30%;    /*水平 竖直*/
4.具体的数值:background-position:20px 30px;  /*水平 竖直*/

(5)背景关联:

background-attachment:

scroll:默认
fixed:当页面滚动时,背景图片不动

背景样式符合写法

    background:#666 url(‘images/1.jpg’) no-repeat center/cover fixed ;

背景:背景颜色 背景图片 背景重复 背景位置/背景大小 背景关联

上一篇下一篇

猜你喜欢

热点阅读