25
2018
07

background: url的全部介绍

方法/步骤

1

background-color规定要使用的背景颜色。

background-position规定背景图像的位置。

background-size规定背景图片的尺寸。

background-repeat规定如何重复背景图像。

background-origin规定背景图片的定位区域。

background-clip规定背景的绘制区域。

background-attachment规定背景图像是否固定或者随着页面的其余部分滚动。

background-image规定要使用的背景图像。

2

background: #ff0000 url(/i/eg_bg_03.gif) no-repeat  50% 50% fixed;

第一个参数是背景颜色,第二个参数背景图片,第三个参数是否平铺(repeat-x,横向平铺;repeat-y,纵向平铺),第四个参数距左边距离可以用像素(20px);第五个参数是距上距离;第六个参数是背景图片固定还是随着滚动条滚动。

3

background-size:100%;可以让背景图片平铺背景,但是要注意图片大小,避免被过度拉伸失真。

« 上一篇下一篇 »