freeCodeCamp/guide/chinese/css/properties/width-property/index.md

25 lines
821 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
title: Width Property
localeTitle: 宽度属性
---
## 宽度属性
width属性设置元素的宽度。它可以是关键字值长度值任何值后跟CSS单位如px或em百分比或者它可以由它的父级继承。默认情况下它的值是auto。
**注意** width属性不包括填充边框或边距;它设置元素的填充,边框和边距内的区域宽度!
```css
.length-value {width: 100px;}
.percentage {width: 50%;}
.auto {width: auto;}
.inherit {width: inherit;}
.initial {width: initial;}
```
**注意** min-width和max-width属性覆盖宽度。
#### 更多信息:
文件: [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/width)
浏览器支持:它被归类为“支持良好的子集”,因此无需担心浏览器支持