css 背景平铺

html-css06

css 背景平铺,第1张

不平铺应该是background-repeat:no-repeat背景图片等于整个网页的宽和整个网页的高不好实现,因为图片会变形,屏幕太大会让图片失真,用大图片又会影响网页打开速度,

如果是要平铺的图片只能做成单张的图片,集合图片(css

sprite)是不行的。

至于实现平铺效果用:

background-repeat:repeat

background-repeat:repeat-y

background-repeat:repeat-x

再看看别人怎么说的。

需要准备的材料分别有:电脑、浏览器、html编辑器。

1、首先,打开html编辑器,新建html文件,例如:index.html。

2、在index.html中的<style>标签中,输入css代码:body {background: url(image.jpg) no-repeatbackground-size: 100%}。

3、浏览器运行index.html页面,此时成功设定背景图片等比例放缩到网页宽度。