CSS基础知识点记录

CSS参考手册

1、CSS(层叠样式表):描述元素的皮肤,美化页面。

2、CSS使用方式:内联、页面嵌入和外部引用。

2.1、内联

    

2.2、页面嵌入

    
    
    Document
    
    

所有input标签都被设置成该样式。

2.3、外部引用



Document


3、CSS计量单位:px(像素)、30%(百分比)、em(相对单位)等。

4、将光标设置成图标样式。图标格式必须是".cur"或"ani"格式才行。

例如:


5、样式选择器:标签选择器、class选择去器、id选择器。

对于非元素内联的样式需要定义样式选择器。

5.1、标签选择器(对于指定的标签采用统一的样式)

例如:

input{border-color: Yellow;color: Red;}

5.2、class选择器

定义一个命名的样式,然后在用到它的时候设置元素的class属性为样式的名称,还可以同时设置多个class,名称之间加空格。

例如:


.warning{backgroud: Yellow;}
.highlight{font-size: xx-large;cursor: help;}

你好
我好
大家好

标签+class选择器

class选择器也可以针对不同的标签,实现同样的样式名对于不同的标签有不同的样式,只要在样式名前加标签名即可。

例如:


input.accountno{text-align: right;color: Red;}
label.accountno{font-style: italic;}



5.3、id选择器

为指定id的元素设置样式,id前加#。

例如:


#username
{
    font-size: xx-large;
}


5.4、其他选择器(不常用)

  • 关联选择器:

例如:
P strong{background-color: Yellow;}
表示P标签内的strong标签内的内容使用的样式。

  • 组合选择器:

同时为多个标签设置一个样式。
例如:
h1,h2,input{background-color: Green;}

  • 伪选择器:

为标签的不同状态设置不同的样式。
a:visited:超链接点击过的样式 。
a:active:选中超链接时的样式。
a:link:超链接未被访问时的样式。
a:hover:鼠标移到超链接时的样式。
例如:

a:visited{text-decoration: none;}
a:active{text-decoration: none;}
a:link{text-decoration: none;}
a:hover{text-decoration: underline;}

你可能感兴趣的:(CSS基础知识点记录)