For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt, and this page is available as Markdown at /next/zh/api/css/properties/box-sizing.md.
Lynx
  • 简体中文
  • box-sizing

    介绍

    box-sizing 决定元件的 widthheightmin-widthmin-heightmax-widthmax-height 如何解析。

    使用示例

    语法

    box-sizing: border-box;
    box-sizing: content-box;

    取值

    • border-box

      默认值。widthheight 属性包括内容 (content),内边距(padding),和边框(border),但不包括外边距(margin)。

      尺寸计算公式:

      width = border + padding + content

      height = border + padding + content

    • content-box

      标准盒子模型。widthheight 只包括内容 (content),不包括边框(border),内边距(padding),外边距(margin)。

      尺寸计算公式:

      width = content

      height = content

    形式定义

    初始值border-box
    适用元素所有元件
    是否支持继承
    是否支持动画

    形式语法

    box-sizing = border-box | content-box

    与 Web 的区别

    • Lynx 的默认值为 border-box,Web 的默认值为 content-box
    • box-sizing 不会影响 flex-basis 的取值。

    兼容性

    LCD tables only load in the browser

    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。