您好,欢迎来到欧宁财经。
搜索
您的当前位置:首页background-image属性怎么用

background-image属性怎么用

来源:欧宁财经
 background-image属性是用来设置元素的一个或多个背景图像,用逗号(,)分隔。

CSS background-image属性

作用:background-image属性为元素设置背景图像。

语法:

background-image:url(图片路径)

说明:background-image属性设置的背景图像会占据了元素的全部尺寸,包括内边距和边框,但不包括外边距。默认地,背景图像位于元素的左上角,并在水平和垂直方向上重复。

提示:请设置一种可用的背景颜色,这样的话,假如背景图像不可用,可以使用背景色带代替。

CSS background-image属性的使用示例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 

<style>
#example1 {
 background-color:#cccccc;
 background-image:url("https://img.php.cn/upload/article/000/000/024/5c6a290265dba776.gif"),url("https://img.php.cn/upload/article/000/000/024/5c6a2793a13ac244.gif");
 background-position: right bottom, left top;
 background-repeat: no-repeat, repeat;
 padding: 15px;
}
</style>
</head>
<body>

<div id="example1">
<h1>Hello World!</h1>
<p>测试文本!测试文本!测试文本!测试文本!测试文本!测试文本!测试文本!</p>
<p>测试文本!测试文本!测试文本!测试文本!测试文本!测试文本!测试文本!测试文本!测试文本!测试文本!</p>
</div>

</body>
</html>

效果图:

Copyright © 2019- onup.cn 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务