“Pr dim width”的版本间差异
本页内容
(创建页面,内容为“{{DISPLAYTITLE:width}}7 = CSS width 属性 = 设置一个段落的高度和宽度: <sample title="" desc="" lang="html" hererun="1"> p.ex { height:100px; width:100px; } </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <style> img.normal { height:auto; } img.big { height:120px; } p.ex { height:100px; width:100px; } </sty…”) |
无编辑摘要 |
||
(未显示同一用户的1个中间版本) | |||
第1行: | 第1行: | ||
{{DISPLAYTITLE:width}}[[Category:css | {{DISPLAYTITLE:width}}[[Category:css reference|100]] | ||
= CSS width 属性 = | = CSS width 属性 = | ||
第76行: | 第76行: | ||
{| class="table table-striped table-hover" | {| class="table table-striped table-hover" | ||
! 属性 | ! 属性 | ||
! | ! Chrome | ||
! | ! Internet Explorer / Edge | ||
! | ! Firefox | ||
! | ! Safari | ||
! | ! Opera | ||
|- | |- | ||
| width | | width |
2022年8月19日 (五) 04:45的最新版本
CSS width 属性
设置一个段落的高度和宽度:
示例
p.ex
{
height:100px;
width:100px;
}
属性定义及使用说明
width属性设置元素的宽度。
注意: width属性不包括填充,边框和页边距!
默认值: | auto |
继承: | no |
版本: | CSS1 |
JavaScript 语法: | object.style.width="50px" |
浏览器支持
表格中的数字表示支持该属性的第一个浏览器版本号。
属性 | Chrome | Internet Explorer / Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
width | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
属性值
值 | 描述 |
---|---|
auto | 默认值。浏览器可计算出实际的宽度。 |
length | 使用 px、cm 等单位定义宽度。 |
% | 定义基于包含块(父元素)宽度的百分比宽度。 |
inherit | 规定应该从父元素继承 width 属性的值。 |
更多实例
使用百分比来设置元素的宽度 本例演示如何使用百分比值来设置元素的宽度。
相关文章
CSS 教程: CSS Dimension
CSS 教程: CSS Box model
CSS 参考手册: height 属性