在线文档教程
CSS
背景和边框 | Backgrounds & Borders

左边框宽度 | border-left-width

边框左宽

border-left-width CSS属性设置一个框的左边框的宽度。

/* Keyword values */ border-left-width: thin; border-left-width: medium; border-left-width: thick; /* <length> values */ border-left-width: 10em; border-left-width: 3vmax; border-left-width: 6px; /* Global keywords */ border-left-width: inherit; border-left-width: initial; border-left-width: unset;

初始值medium
适用元素all elements. It also applies to ::first-letter.
是否是继承属性no
适用媒体visual
计算值the absolute length or 0 if border-left-style is none or hidden
Animation typea length
正规顺序the unique non-ambiguous order defined by the formal grammar

语法

<br-width>定义边界的宽度,可以是明确的非负值<length>或关键字。如果是关键字,则必须是以下值之一:

thinA thin border
mediumA medium border
thickA thick border

注意:由于规范没有定义每个关键字所表示的精确厚度,因此使用其中一个关键字的精确结果是特定于实现的。尽管如此,它们总是遵循这个模式thin ≤ medium ≤ thick,价值在一个单一的文件中是不变的。

正式语法

<br-width>where <br-width> = <length> | thin | medium | thick

示例

HTML

<div>Element 1</div> <div>Element 2</div>

CSS

div { border: 1px solid red; margin: 1em 0; } div:nth-child(1) { border-left-width: thick; } div:nth-child(2) { border-left-width: 2em; }

结果

规范

SpecificationStatusComment
CSS Backgrounds and Borders Module Level 3The definition of 'border-left-width' in that specification.Candidate RecommendationNo significant change.
CSS Level 2 (Revision 1)The definition of 'border-left-width' in that specification.RecommendationNo significant change.
CSS Level 1The definition of 'border-left-width' in that specification.RecommendationInitial definition.

浏览器兼容性

FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support1.0(Yes)1.0 (1.0)4.03.51.0 (85)

FeatureAndroidEdgeFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support2.3(Yes)1.0 (1.0)6.0111.0

另见

  • 其他的border-width相关的CSS属性:border-bottom-widthborder-right-widthborder-top-width,和border-width

  • 另外左边框相关的CSS属性:borderborder-leftborder-left-style,和border-left-color