现在的位置: 首页 > 综合 > 正文

css学习笔记一

2012年05月11日 ⁄ 综合 ⁄ 共 1308字 ⁄ 字号 评论关闭

1.  css作用

   将文档与格式分离 ;    更好地控制网页布局;     网页体积更小

   css通过规则控制页面,规则分选择和说明两部分。选择可以是任何html标签,说明包括属性和属性值两部分,说明被符号“{ }”包含。

2.  css使用

  2.1 植入式

     直接将样式表添加在网页的<body>之前

    <style type="text/css">

   <--

      样式规则

  -->

 2.2 链接式

    将外部css文件链接进文档

   <LINK  rel=stylesheet url="mycss.css" type="text/css">

 2.3 输入式

    与链接式相似,但可以与其他方法同用

    <style type="text/css">

   <--

      @import  url("mycss.css");

      其他样式规则

  -->

 2.4 行内式

   <p style="font-family:">

 

 

   <--

      @import  url("mycss.css");

      其他样式规则

  -->

 2.4 行内式

   <p style="font-family:">

 

 

   <--

      @import  url("mycss.css");

      其他样式规则

  -->

 2.4 行内式

   <p style="font-family:">

3. css技巧

   分类:将一个选择分为不同类别,可对不同类别实施不同的控制。如:

   p.first {color: green}

   p.second {color: red}

   p.third {color: gray}

   <p class = first>this is the first class</p>

  或直接用类别名:.first {color: green} 这样所有此类别的内容颜色都为绿色,而不止局限在<p>标签内

4.css定位控制

4.1 绝对定位

   p <position: absolute; left: 100px;  top: 40px>

4.2 相对定位

  p <position: relative; left: 100px;  top: 40px>

  相对于元素应该出现的位置进行定位

4.3 可视性

  p <visibility: hidden>

4.4 重叠要素

  p <z-index: 1>

  多个要素共占同一区域时,z-index值最大的要素在最上方,最小的在最下方

 5.css字体控制

5.1  字模系列:字体名称    即属性font-family的值

5.2  字号:即属性font-size的值。

    字号单位:Points (pt)、Ems(em)、Pixels(px)

           in (英寸) cm (厘米) mm (毫米)

          pc (打字机字型尺寸单位) ex (x-height)

   字号关键字:

  • xx-small
  • x-small
  • small
  • medium
  • large
  • x-large
  • xx-large
  • 5.3 字体风格: font-style

        参数值:italic   Oblique    normal

    5.4 字重:  font-weight

        参数值:bold  normal

           或 100  200 .......900


    抱歉!评论已关闭.