学习日记52---css学习

  1. css(cascading style sheets 层叠样式表)。html只负责文档的结构和内容,表现形式完全交给css,使html文档变得简洁。
  2. 定义方法: 选择器{属性:值;属性:值;属性:值;}
  3. css页面引入方法:
    1. 内联式:< div style:”color:red;font-size:12px”>…<div>
    2. 嵌入式:在头文件中(首页常用此法,速度快)

      <style type="text/css">
      div{
      color:red;
      font-size:20px;
      line-height: 40px;
      }
      </style>

      会自动为后面的div块套入样式
    3. 外链式

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

      其中css/main.css里为style里的div内容。
  4. css常用文本设置 ★

    • color 设置文字的颜色,如: color:red;
    • font-size 设置文字的大小,如:font-size:12px;
    • font-family 设置文字的字体,如:font-family:’微软雅黑’;
    • font-style 设置字体是否倾斜,如:font-style:’normal’; 设置不倾斜,font-style:’italic’;设置文字倾斜
    • font-weight 设置文字是否加粗,如:font-weight:bold; 设置加粗 font-weight:normal 设置不加粗
    • font 同时设置文字的几个属性,写的顺序有兼容问题,建议按照如下顺序写: font:是否加粗 字号/行高 字体;如: font:normal 12px/36px ‘微软雅黑’;(字号/行高 在前,字体在后)
    • line-height 设置文字的行高,如:line-height:24px;
    • text-decoration 设置文字的下划线,如:text-decoration:none; 将文字下划线去掉
    • text-indent 设置文字首行缩进,如:text-indent:24px; 设置文字首行缩进24px
    • text-align 设置文字水平对齐方式,如text-align:center 设置文字水平居中
  5. 颜色表示法

    1. 颜色名表示,red,yellow等
    2. rgb表示,rgb(255,0,0)
    3. 16进制数表示,#ff0000

猜你喜欢

转载自blog.csdn.net/dershine/article/details/82694729