本主题列出了支持的 USS 属性及其接受的值。
USS 数据类型定义 USS 属性接受的值和关键字。
#hexadecimal code, rgb(), or rgba(). Color keywords such as blue or transparent are not supported.UIElements 样式属性使用与 W3C CSS 文档相同的语法句法:
auto、baseline。< 和 >)之间。例如:<length>、<color>。<' and '>). For example, <‘width’>.如果属性值包含多个组件:
|) separates two or more alternatives: exactly one must occur.||) separates two or more options: one or more must occur, in any order.&&) 分隔两个或多个组件:全部都必须出现,顺序任意。[ ]) 表示分组。每个类型、关键字或尖括号组的后面都可以跟修饰符:
*) 表示前面的类型、词或组出现零次或多次。+) 表示前面的类型、词或组出现一次或多次。?) 表示前面的类型、词或组是可选的。{A,B}) 表示前面的类型、词或组出现至少 A 次且最多 B 次。如果没有为继承的属性指定任何值,该元素将从其父元素获取值。例如,使用继承的属性来设置所有元素的字体。
:root {
-unity-font: resource("Font/consola.ttf");
}
继承的属性如下:
width 和 height 指定元素的大小。如果未指定 width,则宽度基于元素内容的宽度。如果未指定 height,则高度基于元素内容的高度。
margin 简便选项的应用方式如下:
margin-top and margin-bottom. The second is applied to margin-left and margin-right.margin-top. The second is applied to margin-left and margin-right. The third is applied to margin-bottom.margin-top, margin-right, margin-bottom, margin-left
border-width 简便选项的应用方式如下:
border-top-width and border-bottom-width. The second is applied to border-left-width and border-right-width.border-top-width. The second is applied to border-left-width and border-right-width. The third is applied to border-bottom-width.border-top-width, border-right-width, border-bottom-width, border-left-width
padding 简便选项的应用方式如下:
padding-top and padding-bottom. The second is applied to padding-left and padding-right.padding-top. The second is applied to padding-left and padding-right. The third is applied to padding-bottom.padding-top, padding-right, padding-bottom, padding-left
本节列出了用于定位视觉元素的属性。UIElements 包括一个布局引擎,可根据布局和样式属性定位视觉元素。该布局引擎实现了名为 Flexbox 的 HTML/CSS 布局系统的子集。
默认情况下,所有项都垂直放置在其容器中。
默认情况下,此属性设置为 relative:根据父级来定位元素。如果此属性设置为 absolute,则元素将保留其父级布局,并根据父级边界指定值。
相对于元素父级边缘或原始位置的距离。
绘制属性用于设置视觉元素的背景、边框和外观。
分配背景图像时,可以根据简化的九宫格规范来绘制该图像:
border-radius 简便选项的应用方式如下:
border-top-left-radius and border-bottom-right-radius. The second is applied to border-bottom-left-radius and border-top-right-radius
border-top-left-radius. The second is applied to border-bottom-left-radius and border-top-right-radius. The third is applied to border-bottom-right-radius.border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius
The display default value is flex. Setting display to none removes the element.
文本属性用于设置颜色、字体、字体大小以及 Unity 特有属性(字体资源、字形、对齐、自动换行和剪切)。
使用 cursor 默认纹理类型可为光标导入自定义纹理。
cursor: [ [ <resource> | <url> ][ <integer> <integer>]? , ][ arrow | text | resize-vertical | resize-horizontal | link | slide-arrow | resize-up-right | resize-up-left | move-arrow | rotate-arrow | scale-arrow | arrow-plus | arrow-minus | pan | orbit | zoom | fps | split-resize-up-down | split-resize-left-right ]