当前位置: 首页 > 图文教程 > 网页制作 > CSS样式表 > CSS3教程(5):网页背景图片

CSS样式表
css 兼容ie6,ie7,ff的fixed,元素上下端固定定位方法
CSS解决链接锚点定位偏移的代码
一个css transform效果 很有图片的感觉
ie6,ie7,firefox的textarea滚动条、边框
12种CSS BUG解决方法与技巧
CSS 常用设置备忘
table中td内容换行问题
外部引用CSS中 link与@import的区别
CSS background-position 属性 定位图片
css 解决英文字符与阿位伯数字自动换行
div ,frame等空间的透明实现代码
CSS中几种浏览器对不同版本的支持与区分写法
多个浏览器对容器宽度实际像素的解释
CSS 用ul li做圆角表格
CSS 之dl dt dd模拟表格实例代码
创建超链接及css 样式设置
页面位置 top、postop、scrolltop、offsetTop、scrollHeight、offsetHeight、clientHe
css float 解析学习
学习DIV+CSS难不难 需要掌握哪些知识
IE8 CSS hack

CSS样式表 中的 CSS3教程(5):网页背景图片


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-09   浏览: 49 ::
收藏到网摘: n/a

背景图片/纹理有很多种使用方式,常常用于添加网站的最佳的最终美化。现在它在CSS3中被重视,我们可以应用多背景图和背景图片尺寸来实现更完美的效果。

CSS3的背景图片大小可以写成 background-size:Apx Bpx;
-Apx = x轴(图片宽度)
-Bpx = y轴(图片高度)

了解了这些,我们开始体验这个特性吧:
最好支持CSS3背景大小的浏览器是Safari和Opera,所以我们只需要使用-o和-webkit前缀。

背景大小

background-size

#backgroundSize{	border: 5px solid #bd9ec4;	background:url(image_1.extention) bottom right no-repeat;	-o-background-size: 150px 250px;	-webkit-background-size: 150px 250px;	padding: 15px 25px;	height: inherit;	width: 590px;
}

浏览器支持:

  • Firefox(3.05+…)
  • Google Chrome(1.0.154+…)
  • Google Chrome(2.0.156+…)
  • Internet Explorer(IE7, IE8 RC1 )
  • Opera(9.6+…)
  • Safari(3.2.1+ windows…)

为了在CSS3中应用多背景图片,我们使用都好隔开,例如:

background: url(image_1.extention) top right no-repeat, url(image_2.extention) bottom right no-repeat;

我们可以在一行代码中尝试放置多个不同的图片…

多背景图

background-size

#backgroundMultiple{	border: 5px solid #9e9aab;	background:url(image_1.extention) top left no-repeat,	url(image_2.extention) bottom left no-repeat,	url(image_3.extention) bottom right no-repeat;	padding: 15px 25px;	height: inherit;	width: 590px;
}

浏览器支持:

  • Firefox(3.05+…)
  • Google Chrome(1.0.154+…)
  • Google Chrome(2.0.156+…)
  • Internet Explorer(IE7, IE8 RC1 )
  • Opera(9.6+…)
  • Safari(3.2.1+ windows…)