CSS概述

css是英文Cascading Style Sheets的缩写,称为层叠样式表,用于对页面进行美化。

存在方式有三种:元素内联、页面嵌入和外部引入:

 语法:style='key1:value1;key2:value2;'

  • 在标签中使用 style='xx:xxx;'

  • 在页面中嵌入 <style type="text/css"> </style> 块

  • 引入外部css文件<link rel="stylesheet" type="text/css" href="css/common.css" >

 必要性:美工会对页面的色彩搭配和图片的美化负责,开发人员则必须知道是如何实现的。

各种选择器

标签选择器

div{ background-color:red; } 
 

class选择器

.bd{ background-color:red; } 
 

id选择器

#select{ background-color:red; } 
 

关联选择器

#select p{ background-color:red; } 
 

 

 

组合选择器

input, div, p{ background-color:red; }

属性选择器

input[type='text']{ width:100px; height:200px; }

CSS常用属性

background

  • background-color 

  • background-p_w_picpath

  • background-repeat(no-repeat;repeat-x;repeat-y)

  • background-position

border

    /* 实体框 */
    /* 点点框 */
    /* 虚线框 */

margin

    

padding

    

display

  • display:none;    /* 连同位置一起隐藏 */

  • display:block;

  • display:inline;

visibility

  • visibility:hidden;    /* 内容隐藏,但位置还在 */

  • visibility:visible;

cursor

        
  • css提供的cursor值
  •     

            

    pointer ||        
    help ||        
    wait ||        
    move ||        
    crosshair    

        
  • 伪造超链接
  •     

            

    pointer    

        
  • 自定义(一般不用)
  •     

            

    mine    

浮动

    
left    
right    
    /* 将漂浮的标签拽下来,撑起父标签,要不父标签就看不见了 */

position

透明度