25 lines
821 B
Markdown
25 lines
821 B
Markdown
---
|
||
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)
|
||
|
||
浏览器支持:它被归类为“支持良好的子集”,因此无需担心浏览器支持 |