是一个用于指定所用背景色的选项.
Background
是一个用于指定所用背景色的选项.
更多信息
- Background 可以设定为任意颜色或不透明度.
- Background 是 Graphics、Plot、Text、Panel、Button 和 Cell 等函数的选项.
- 若是一个对象具有选项 Background->color,则所指定的颜色通常将被作为该对象所定义的整个区域的背景色.
- Style[expr,Background->color] 指定 color 仅作为 expr 边界框定义区域的背景色.
- 在诸如 Grid 的结构中,Item 用以指定填充一个特殊项完整区域的背景.
- 在顶层单元中,背景仅用于单元框架内的区域. 如果单元的背景颜色与其周围环境不匹配,即使没有绘制单元框架,单元也会包含单元框架边距. 显示为内联、附加等格式的单元不会受到类似影响. »
- Background->None 指定无背景,这样的背景效果是透明的.
- Background->Automatic 指定的背景和特殊对象的系统外部表征或窗口所用的一致. 对于 Inset 来说,Background->Automatic 意指将图形中的背景去除.
- 对于 Grid、Column 和 Row 对象,可将 Background 设置为一个列表,该列表能对个别的列、行或元素指定背景.
- 在 Dataset 中,Background 的设置可以是返回一组颜色的纯函数 f. 设置由 f[item,position,data] 给出,其中 data 是数据集的第一个参数.
范例
打开所有单元 关闭所有单元范围 (4)
推广和延伸 (5)
在 Dataset 中根据数值设置背景的颜色:
应用 (3)
属性和关系 (2)
使用 CellFrameMargins 绘制具有对比背景色且没有单元框架的单元:
与环境匹配的背景色仅当存在单元框架时才使用 CellFrameMargins:
BackgroundNone 被视为匹配的背景色:
CellFrameMargins 不适用于显示为内联、附加、浮动等格式的单元:
可能存在的问题 (1)
某些背景色在浅色模式下与默认字体颜色对比良好,但在深色模式下效果不佳:
这些问题可以通过将颜色封装在 LightDarkSwitched 中解决:
使用 LightDarkSwitched 并将 Automatic 作为第一个参数即可解决这些问题:
参见
Prolog PlotRegion ImageMargins Item Panel Framed CellFrame Style WindowOpacity LightDarkSwitched ThemeColor
Function Repository: HighlighterPalette
相关链接
历史
1991年引入 (2.0) | 在以下年份被更新:1996 (3.0) ▪ 2007 (6.0) ▪ 2012 (9.0) ▪ 2020 (12.1)
文本
Wolfram Research (1991),Background,Wolfram 语言函数,https://reference.wolfram.com/language/ref/Background.html (更新于 2020 年).
CMS
Wolfram 语言. 1991. "Background." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2020. https://reference.wolfram.com/language/ref/Background.html.
APA
Wolfram 语言. (1991). Background. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/Background.html 年
BibTeX
@misc{reference.wolfram_2025_background, author="Wolfram Research", title="{Background}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/Background.html}", note=[Accessed: 30-April-2026]}
BibLaTeX
@online{reference.wolfram_2025_background, organization={Wolfram Research}, title={Background}, year={2020}, url={https://reference.wolfram.com/language/ref/Background.html}, note=[Accessed: 30-April-2026]}