## background-color background-color 属性用于设置元素的背景色,属性的值为颜色值或关键字"transparent"。 ### uni-app x 兼容性 Web: 4.0; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61 ### App平台拍平(flatten)兼容性 @flatten_compatibility | Android(Vapor) | iOS(Vapor) | HarmonyOS(Vapor) | | :- | :- | :- | | 5.21 | 5.11 | 5.0 | ### 语法 ``` background-color: ; ``` ### 值限制 - color ### 默认值 @default-value `transparent` ### tips@tips - App-Harmony 平台,背景仅延伸到内边距(padding)区域,不会绘制到边框区域,效果与 background-clip 为 padding-box 一致。 ### 示例 示例为[hello uni-app x alpha分支](https://gitcode.com/dcloud/hello-uni-app-x/blob/prod_alpha/pages/CSS/background/background-color.uvue),与最新HBuilderX Alpha版同步。与最新正式版同步的master分支示例[另见](https://gitcode.com/dcloud/hello-uni-app-x/blob/master//pages/CSS/background/background-color.uvue) ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/CSS/background/background-color > appRedirect https://hellouniappx.dcloud.net.cn/appredirect.html?path=pages/CSS/background/background-color >示例 ```vue ``` ::: ### 参见 - [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/background-color) - [相关 Bug](https://issues.dcloud.net.cn/?mid=css.properties.background.background-color)