码迷,mamicode.com
首页 > 其他好文 > 详细

背景样式

时间:2016-07-17 02:55:35      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:背景样式   css   

背景颜色background-color


background-color属性可以控制HTML元素的背景颜色

background-color的属性结构是:

- background-color:value;


#wrapper{
        width:150px;
        height:150px;
        background-color:#f00;
}
<div id="wrapper"></div>

技术分享


背景图像background-image


background-image属性可以控制HTML元素的背景图像

语法结构

background-image:url(图像url);

默认情况下,背景图像将重复显示。


#wrapper{
        width:150px;
        height:150px;
        background-image:url(images/Centos.png);
}
<div id="wrapper"></div>

技术分享


背景重复background-repeat


background-repaeat属性可以控制背景图像的重复方式

background-repaeat语法结构:

background-repaeat:repeat|no-repeat|repeat-x|repeat-y;


#wrapper{
        width:150px;
        height:150px;
        background-image:url(images/Centos.png);
        background-repeat:repeat-x;
        border:1px solid red;
}
<div id="wrapper"></div>

技术分享


背景附着background-attachment


background-attachment属性设置背景图像是否固定或者随着页面其余部分滚动

background-attachment的语法结构是:

background-attachment:scroll|fixed;

- scroll 默认值,背景图像会随着页面其余部分的滚动而滚动。

- fixed 当页面的其余部分滚动时,背景图像不会移动。


背景定位background-position


background-position属性可以设置背景图像的位置


属性值说明

top left

top center

top right

center left

center center

center right

bottom left

bottom center

bottom right

如果仅规定了一个关键词,那么第二个值将是“center”

默认值:0% 0%

xpos ypos

第一个值是水平位置,第二个值是垂直位置。

左上角是 0 0,单位是像素(0px 0px)或任何其他的CSS单位


背景属性background


background属性在一个声明中设置所有的背景属性

语法结构

- background:color url(图像的url) repeat attachment position;


本文出自 “擎凇离雨痴木月” 博客,请务必保留此出处http://kinrey.blog.51cto.com/10492082/1826914

背景样式

标签:背景样式   css   

原文地址:http://kinrey.blog.51cto.com/10492082/1826914

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!