20150917-css

一、什么叫做CSS样式?

 

(1)CSS (Cascading Style Sheet)叠层样式表。用于控制网页样式并允许将样式信息与网页内容分离的一种标记性语言。

 

(2)CSS有四种控制方法:行内样式、内联样式、链接式、导入式  

 

(注:按就近原则排列)

 

1、行内样式

 

<body>

 

    <div style="color:red";></div>

 

</body>

 

2、内联样式

 

   <head>

 

      <title>这是内联</title>

 

           <style type="text/css">

 

                   div{

 

                      color:red;

 

                      }

 

          </style>

 

   </head>

 

3、链接式

 

<link rel="stylesheet" type="text/css" href="base.css"/>

 

4、导入式:(很少使用了)

 

<style>

 

  @import url(base.css)

 

</style>

 

CSS选择器:

 

1、标签选择器

 

       div{

 

           width:200px;

 

           height:300px;

 

           color:red;

 

 }

<div>...</div>

2、id(#)选择器(具有唯一性)

 

     #c1{

 

     width:200px;

 

     height:300px;

 

     color:red;

 

}

<div id="c1">...</div>

 3、class(.)选择器

 

  .d1{ 

 

  width:200px;

 

     height:300px;

 

     color:red;

 

}

<div class="d1">...</div>

优先级:标签选择器<  class < id

 

css注释符号:/* css内容 */

 

 

 

二、css字体效果:

  文字大小:font-size:14px

  字体: font-family:"微软雅黑"

  字体颜色: color:#FF0000;

  文字粗细:font-weight:bold;

  文字下划线、删除线、定划线

  Text-decoration:underline /*下划线*/

  Text-decoration:overline /*顶划线*/

  Text-decoration:line-through; /*删除线*/

posted on 2015-09-20 17:36  我是肥雄  阅读(110)  评论(0编辑  收藏  举报

导航