html可以加多个背景图片。html中,可以借助background-image或者background为一个容器设置多张背景图像,即把不同背景图象只放到一个块元素里;语法“background:url(图片地址),url(地址)..;”。
本教程操作环境windows7系统、css3&&html5版、dell g3电脑。
html中,可以借助background-image或者background为一个容器设置多张背景图像,这么说来可以把不同背景图象只放到一个块元素里。
首先我们来看一下语法吧
background [background-image] | [background-origin] | [background-clip] | [background-repeat] | [background-size] | [background-attachment] | [background-position]多个背景图片的url之间使用逗号隔开即可,如果有多个背景图片,但是其他属性只有一个(例如background-repeat只有一个),这样的话所有背景图片都应用该属性值。
下面我们就看一个例子吧
body { background-image: url(https://image.flaticon.com/icons/svg/748/748122.svg), url(https://images.unsplash.com/photo-1478719059408-592965723cbc?ixlib=rb-1.2.1&auto=format&fit=crop&w=2212&q=80); background-position: center, top; background-repeat: repeat, no-repeat; background-size: contain, cover;}推荐教程《html视频教程》