七天学会html5和css3之背景详细介绍分析(25)

CSS 背景(background)目标- 理解 - 背景的作用 - css背景图片和插入图片的区别- 应用 - 通过css背景属性,给页面元素添加背景样式 - 能设置不同的背景图片位置4.1 背景颜色(color)- 语法: background-color:颜色值; 默认的值是 transparent 透明的4.2 背景图片(image)- 语法:```cssbackground-image : none | url (url)`...
摘要由CSDN通过智能技术生成

 CSS 背景(background)

目标

- 理解
  - 背景的作用
  - css背景图片和插入图片的区别
- 应用
  - 通过css背景属性,给页面元素添加背景样式
  - 能设置不同的背景图片位置

4.1 背景颜色(color)

- 语法:


  background-color:颜色值;   默认的值是 transparent  透明的
  

4.2 背景图片(image)

- 语法: 

```css
background-image : none | url (url) 
```

| 参数 |              作用              |
| ---- | :----------------------------: |
| none |       无背景图(默认的)       |
| url  | 使用绝对或相对地址指定背景图像 |

`css
background-image : url(images/demo.png);
 

- 小技巧:  我们提倡 背景图片后面的地址,url不要加引号。


<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		.bg {
			width: 800px;
			height: 500px;
			background-color: pink;
			/*背景图片 1. 必须加url 2. url 里面的地址不要加 引号*/
			background-image: url(images/l.jpg);
		}
	</style>
</head>
<body>
	<div class="bg">
		12312312312312312312312312312
	</div>
</body>
</html>

4.3 背景平铺(repeat)

- 语法: 

```css
background-repeat : repeat | no-repeat | repeat-x | repeat-y 
```

| 参数      |                 作用                 |
| --------- | :----------------------------------: |
| repeat    | 背景图像在纵向和横向上平铺(默认的) |
| no-repeat |            背景图像不平铺            |
| repeat-x  |         背景图像在横向上平铺         |
| repeat-y  |          背景图像在纵向平铺          |


<
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值