Files
freeCodeCamp/guide/chinese/css/background-size/index.md
范鼎 0fbbfc993a Update code format (#21779)
* 格式调整

* fix: correct Mozilla link for Chinese version
2018-11-23 16:52:39 -08:00

36 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Background Size
localeTitle: 背景大小
---
## 背景大小
background-size属性指定背景图像的大小。您可以设置长度或百分比第一个值是宽度第二个值是高度。您还可以使用以下5个关键字值之一
```css
.auto {background-size: auto;}
.cover {background-size: cover;}
.contain {background-size: contain;}
.initial {background-size: initial;}
.inherit {background-size: inherit;}
/* Percentage and pixel can also be used */
.pixel {background-size: 50px 50px;}
.percentage {background-size: 50% 50%;}
```
要在多个背景图像上设置此属性,请用逗号分隔值:
```css
.multiple {
background-image: url(1.png), url(2.png);
background-size: 3px 3px, cover;
}
```
#### 更多信息:
文档: [MDN](https://developer.mozilla.org/zh-CN/docs/Web/CSS/background-size)
CSS-Tricks [背景大小](https://css-tricks.com/almanac/properties/b/background-size/)
浏览器支持: [caniuse](http://caniuse.com/#search=background-size)