常用属性

34 篇文章 0 订阅

常用属性

一、背景属性

1、语法格式

background: background-color || background-image || background-repeat || background-attachment || background-position

background是一个复合值属性

2、属性

属性版本兼容性继承性简介
backgroundCSS1IE4+ , NS4+复合属性。设置或检索对象的背景特性
background-attachmentCSS1IE4+ , NS6+设置或检索背景图像是随对象内容滚动还是固定的
background-colorCSS1IE4+ , NS4+设置或检索对象的背景颜色
background-imageCSS1IE4+ , NS4+设置或检索对象的背景图片
background-positionCSS1IE4+ , NS6+设置或检索对象的背景图像位置
background-positionXIE专有属性IE5.5+设置或检索对象的背景图像横坐标位置
background-positionYIE专有属性IE5.5+设置或检索对象的背景图像纵坐标位置
background-repeatCSS1IE4+ , NS4+设置或检索对象的背景图像是否及如何铺排

3、添加背景颜色

  1. 语法格式

    background : transparent | color 
    background-color : transparent | color 
    
  2. 参数说明

    可选值说明
    transparent背景色透明
    color指定颜色

  3. 示例代码

    div { background-color: red }
    div { background-color: rgb(223,71,177) } 
    div { background-color: #98AB6F;}
    div { background-color: transparent; }
    

4、添加背景图片

  1. 语法格式

    background : none | url (url)
    background-image : none | url (url)
    
  2. 参数说明

    可选值说明
    none无背景图
    url使用绝对或相对地址指定背景图像
  3. 示例代码

    background-image: url("img/girl.jpg"); 
    background-image: url("http://xxx/xxx.jpg); 
    

5、背景的平铺

  1. 语法格式

    background-repeat : repeat | no-repeat | repeat-x | repeat-y 
    
  2. 参数说明

    可选值说明
    repeat背景图像在纵向和横向上平铺
    no-repeat默认,背景图像不平铺
    repeat-x背景图像在横向上平铺
    repeat-y背景图像在纵向平铺
  3. 示例代码

     div {background-image: url("img/girl.jpg") repeat-y; } 
    

6、背景图片的滚动

  1. 语法格式

    background-attachment : scroll | fixed 
    
  2. 参数说明

    可选值说明
    scroll背景图像是随对象内容滚动
    fixed背景图像固定
  3. 示例代码

     div {background-image: url("img/girl.jpg") no-repeat fixed;  } 
    

7、背景图片的定位

  1. 语法格式

    background-position : length || position
    background : url (url) || length || position
    <!--设置两个值,宽和高-->
    
  2. 参数说明

    可选值说明
    length百分数 | 由数字和单位标识符组成的长度值。
    position英文单词取值 top | center | bottom | left | center | right
  3. 示例代码

    div { background: url("img/girl.jpg"); background-position: 40% 50%; } 
    div { background: url("img/girl.jpg"); background-position: 100 200; } 
    div { background: url("img/girl.jpg";background-position: center center; } 
    注:top left||top center||top right||center left||center center||center right||bottom left||bottom center||bottom right
    

二、文字文本属性

1、文字属性

  1. 属性说明

    属性说明
    color文字颜色
    font-size文字大小
    font-weight文字粗细
    font-family文字字体
    font-variant小写字母以大写字母显示
  2. 示例代码

    color:red;
    font-size:12px;	
    font-weight:“bold”	
    font-family:“宋体”	
    font-variant:small-caps
    

2、文本属性

  1. 属性说明

    属性说明
    text-align文本对齐(right/left/center)
    line-height行间距,可通过它实现文本的垂直居中(与width设置相同值)
    text-indent首行缩进
    text-decoration文本下划线(none/underline/overline/line-through)
    letter-spacing字间距
  2. 示例代码

    text-align:center; 
    line-height:10px;
    text-indent:2em;
    text-decoration:none;
    letter-spacing: 10px;
    

三、表格属性

  1. 语法格式

    border-collapse : separate | collapse 
    border-spacing : length || length 
    
  2. 参数说明

    属性版本兼容性继承性简介
    border-collapseCSS2IE5+是否合并表格边框。
    border-spacingCSS2NONE相邻单元格边框之间的距离。
  3. 示例代码

    //默认的边框分开
    table { border-collapse: separate; } 
    //为表格设置合并边框模型
    table { border-collapse:collapse;} 
    table, td, th
            {
                border:1px solid black;
            }
    

四、尺寸

  1. 属性说明

    属性版本兼容性继承性简介
    heightCSS1IE4+ , NS6+设置元素的高度
    max-heightCSS2NONE设置元素的最大高度
    min-heightCSS2IE6+设置元素的最小高度
    widthCSS1IE4+ , NS6+设置元素的宽度
    max-widthCSS2NONE设置元素的最大宽度
    min-widthCSS2NONE设置元素的最小宽度
  2. 示例代码

五、图片属性

属性可选值说明
vertical-aligntop|middle|bottom|percentage设置图片与文字的对齐方式
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值