非常教程

CSS 参考手册教程

CSS width 属性

CSS width 属性

CSS width 属性


实例

设置一个段落的高度和宽度:

p.ex
{
height:100px;
width:100px;
}

尝试一下 »
在此页底部有更多的例子。

属性定义及使用说明

width属性设置元素的宽度。

注意: width属性不包括填充,边框和页边距!

默认值: auto
继承: no
版本: CSS1
JavaScript 语法: object.style.width="50px"


浏览器支持

表格中的数字表示支持该属性的第一个浏览器版本号。

属性
width 1.0 4.0 1.0 1.0 3.5

属性值

描述
auto 默认值。浏览器可计算出实际的宽度。
length 使用 px、cm 等单位定义宽度。
% 定义基于包含块(父元素)宽度的百分比宽度。
inherit 规定应该从父元素继承 width 属性的值。


CSS width 属性

更多实例

使用百分比来设置元素的宽度
本例演示如何使用百分比值来设置元素的宽度。


相关文章

CSS 教程: CSS Dimension

CSS 教程: CSS Box model

CSS 参考手册: height 属性

CSS width 属性
CSS 参考手册

CSS 参考手册提供了完整的 CSS 属性列表,每个属性都配有语法说明及实例演示,另外还讲解了 CSS 选择器、颜色值及浏览器支持等相关内容。

CSS 参考手册目录

1.CSS 听觉参考手册
2.CSS 选择器
3.CSS 参考手册
4.CSS3 animation-name 属性
5.CSS3 animation 属性
6.CSS3 @keyframes 规则
7.CSS 浏览器支持
8.CSS 颜色十六进制值
9.CSS 颜色名称
10.CSS 合法颜色值
11.CSS 颜色
12.CSS 单位
13.CSS Web安全字体
14.CSS3 animation-timing-function 属性
15.CSS3 animation-duration 属性
16.CSS background-color 属性
17.CSS background-attachment 属性
18.CSS background 属性
19.CSS3 backface-visibility 属性
20.CSS3 appearance 属性
21.CSS3 animation-play-state 属性
22.CSS3 animation-iteration-count 属性
23.CSS3 animation-delay 属性
24.CSS background-repeat 属性
25.CSS background-position 属性
26.CSS background-image 属性
27.CSS border 属性
28.CSS3 background-size 属性
29.CSS3 background-origin 属性
30.CSS3 background-clip 属性
31.CSS border-bottom-style 属性
32.CSS border-bottom-color 属性
33.CSS border-bottom 属性
34.CSS border-right-style 属性
35.CSS border-right 属性
36.CSS border-left-width 属性
37.CSS border-left-style 属性
38.CSS border-left-color 属性
39.CSS Border-left 属性
40.CSS border-color 属性
41.CSS border-collapse 属性
42.CSS border-bottom-width 属性
43.CSS3 border-bottom-left-radius 属性
44.CSS border-width 属性
45.CSS border-top-color 属性
46.CSS border-top-style 属性
47.CSS border-top-width 属性
48.CSS border-top 属性
49.CSS border-style 属性
50.CSS border-spacing 属性
51.CSS border-right-width 属性
52.CSS border-right-color 属性
53.CSS3 border-image-width 属性
54.CSS3 border-radius 属性
55.CSS3 border-top-left-radius 属性
56.CSS3 border-top-right-radius 属性
57.CSS3 border-image-source 属性
58.CSS3 border-image-slice 属性
59.CSS3 border-image-repeat 属性
60.CSS3 border-image-outset 属性
61.CSS3 border-image 属性
62.CSS3 border-bottom-right-radius 属性
63.CSS3 box-sizing 属性
64.CSS3 box-pack 属性
65.CSS3 box-orient 属性
66.CSS3 box-ordinal-group 属性
67.CSS3 box-lines 属性
68.CSS3 box-flex-group 属性
69.CSS3 box-flex 属性
70.CSS3 box-direction 属性
71.CSS3 box-align 属性
72.CSS bottom 属性
73.CSS3 column-rule-color 属性
74.CSS3 column-rule 属性
75.CSS3 column-gap 属性
76.CSS3 column-fill 属性
77.CSS3 column-count 属性
78.CSS color 属性
79.CSS clip 属性
80.CSS clear 属性
81.CSS caption-side 属性
82.CSS3 box-shadow 属性
83.CSS :after 选择器
84.CSS :before 选择器
85.CSS content 属性
86.CSS3 columns 属性
87.CSS3 column-width 属性
88.CSS3 column-span 属性
89.CSS3 column-rule-width 属性
90.CSS3 column-rule-style 属性
91.CSS font 属性
92.CSS float 属性
93.CSS Empty-cells 属性
94.CSS display 属性
95.CSS direction 属性
96.CSS cursor 属性
97.CSS counter-reset 属性
98.CSS counter-increment 属性
99.CSS3 grid-columns 属性
100.CSS3 font-stretch 属性