1. 外联式:通过link标签,连接到外部样式表到页面中。

    <link rel='stylesheet' type = 'text/css' href = 'css/main.css'>
    
  2. 嵌入式:通过style标签,在网页上创建镶嵌入的样式表。

    <style type='text/css'>
      .div{ width :100 px ; height: 100px ; color : red}
    	.........
    </style>
    
  3. 内联式:通过标签的style属性,在标签上直接写样式。

    <div style = 'width : 100px ; height : 100px ; color : red '>
      ......
    </div>
    

CSS文本设置

常用的应用文本的CSS样式:

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

相关文章:

  • 2022-01-17
  • 2021-07-02
  • 2022-12-23
  • 2022-02-28
  • 2021-11-20
  • 2022-12-23
  • 2022-02-10
猜你喜欢
  • 2022-01-13
  • 2022-01-05
  • 2021-11-29
  • 2021-05-28
  • 2022-12-23
  • 2022-12-23
  • 2022-01-06
相关资源
相似解决方案