css随笔1

要用到css,首先就得引入,今天学会了三种css的引入方式:

1.行内引用

<body style="background-color:red;">

<p style="color:#666;">这是行内引用css层叠样式后的P标签</p>

PS:记得要养成良好习惯,写完一个属性 值后加分号,注意是英文状态下哦。

 

2.业内引用

<head>
        <style type="text/css">
            body{
                       background-color:red;
                    }
</head>


<head>
        <style type="text/css">    /*type="text/css" 对浏览器声明应用的是css*/
h1
{ background:red; font-size:12px; }

</head>

ps:虽然<style></style>标签可以定位在任何地方,但是,我们要把它定位在<head></head>之中,因为这样可以以最快的速度加载。    

 

3.外部引用

在css里面:
p{
    font-size:12px;
}
在html里面:
<head>
  <link rel="stylesheet" type="text/css" href="css样式的路径“/>
</head>


在css里面:
h1{
    font-size:12px;
    color:red;
}
在html里面:
<head>
  <link rel="stylesheet" type="text/css" href="css样式的路径“/>
</head>

PS:三种引入方式的优先级:就近原则 -------行内引用>业内引用>页外引用 

 

通配选择符  *

*{
    color:red;
}

*{
   font-size:12px
}

 

元素选择符

h1{
  color:red;
}


p{
   font-size:12px;
}

群组选择符

h1,p{
         color:red;
}


h1,h3,h5,p{
                 font-size:12px;
                 color:red;
 }

 

posted on 2016-08-08 23:41  咦惹-梁泳  阅读(158)  评论(2编辑  收藏  举报

导航