介绍CSS的相关知识

  以下是我跟大家分享的有关CSS的相关知识点:

①什么是CSS?  css(Cascading Style Sheets)是层叠样式表

②css的三种样式使用方法:

1,内联样式表:直接在html标签属性中设置期css样式,也可以称为行内样式。  例:<p style="color:red;"></p>

2,内嵌样式表(嵌入式样式表):在head头部中用<style></style>标签设置css的样式  例:<style>  p { color:red;}  </style>

3,外联样式表:就是将css样式表命名为css文件引入到html文件中。    例:<link rel="stylesheet" style="text/css"  href="1.css"/>

③css中的6种常用的选择器:

1,html标签选择器     例:p{color:red;}

2,id选择器  例:#id名{color:red;}

3,class选择器  例:.class名{color:red;}

4,关联选择器  例:ul  li  p{color:red;}

5,组合选择器  例:p,a,h1{color:red;}

6,伪类选择器:  例:a:link{color:red;}  a:hover{color:red;}  a:active{color:red;}  a:visited{color:red;}

  (注意:使用选择器时,尽量少用id选择器,因为id选择器是给javascript用的)

  选择器的优先级如下:

   关联选择器>id选择器>class选择器>html选择器

css中常见的字体属性和属性值:

1,font-family:字体的族  2,font-size:字体的大小  3,font-weiht:加粗,有三个属性值-----normal正常|bold加粗|lighter变细  4,font-style:字体的样式,有三个属性值------normal|italic(倾斜)|oblique(斜体)  (注意:不是所有的字体都支持倾斜 如果没有倾斜那么你就必须使用斜体来代替倾斜)    5,Font-variant 字体变形   narmal|small-caps。

原文地址:https://www.cnblogs.com/xlboy/p/7247552.html