CSS-width 属性

属性定义及使用说明
width属性设置元素的宽度。
注意: width属性不包括填充,边框和页边距!
默认值: auto 继承: no 版本: CSS1 JavaScript 语法:object.style.width="50px"
属性值
值 描述 auto 默认值。浏览器可计算出实际的宽度。 length 使用 px、cm 等单位定义宽度。 % 定义基于包含块(父元素)宽度的百分比宽度。 inherit 规定应该从父元素继承 width 属性的值。
实例
百分比:
.p img{width:100%}
百分比平分,将三个<li>平均分配
width:calc( 100% / n - ?px)
注:n 平分几份除以几;?px 为一个标签的外表距(也可用百分比)

实际效果

最大宽度:max-width
最小宽度:min-width
相关推荐
-
PHP8种变量类型的详细讲解2025-02-22 00:32:24
-
php+apache 和 php+nginx的区别2025-02-22 00:21:27
-
PHP:与workerman结合实现定时任务2025-02-22 00:15:57
-
Nginx的Rewrite规则与实例2025-02-22 00:15:39
-
MySql中身份证字段的简单脱敏介绍2025-02-22 00:15:36