CSS3之多背景background使用示例_ Div+Css教程-查字典教程网
CSS3之多背景background使用示例
CSS3之多背景background使用示例
发布时间:2017-01-07 来源:查字典编辑
摘要:CSS3中新加了多背景这个属性,和CSS2的使用方法一样,只不过图片可以从1个图片变成多个图片了。在CSS3中多背景的使用是非常常见的,所以...

CSS3中新加了多背景这个属性,和CSS2的使用方法一样,只不过图片可以从1个图片变成多个图片了。在CSS3中多背景的使用是非常常见的,所以,这个多背景的属性应用很普遍的,所以掌握CSS3之多背景background是当务之急呀。

一、background的语法

1、background的分写

background-image: [background-image], [background-image], [background-image];

background-position: [background-position], [background-position], [background-position];

background-repeat: [background-repeat], [background-repeat], [background-repeat];

2、background的简写

background: [background-image] [background-position] [background-repeat],

[background-image] [background-position] [background-repeat],

[background-image] [background-position] [background-repeat];

二、background的兼容情况

三、background的实例

1、圆角效果

CSS代码:

.a {width:300px;}

.b {background:url("http://www.leemagnum.com/img/left.jpg") no-repeat left top,

url("http://www.leemagnum.com/img/right.jpg") no-repeat right top;padding:0 10px;}

.b div {background:url("http://www.leemagnum.com/img/mid.jpg") repeat-x left top;height:48px;}

HTML代码:

<div>

<div>

<div>梦龙小站</div>

</div>

</div>

预览效果:

2、多背景图片

CSS代码:

div {width:300px;height:80px;border:1px solid #000;

background:url("http://www.leemagnum.com/img/logo.jpg") no-repeat,

url("http://www.leemagnum.com/img/a.jpg") no-repeat right -300px;

-webkit-transition:0.5s background-position ease;

}

div:hover {background-position:0 0,right 0;}

HTML代码:

<div></div>

预览效果:

(1)默认状态

(2)hover状态

CSS3之多背景background就为大家介绍完了,希望能对大家有所帮助。CSS3之多背景background在CSS3的项目中运用比较广泛,大家有更好的案例要积极分享哟。

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新 Div+Css教程学习
    热门 Div+Css教程学习
    网页设计子分类