本主题列出了支持的 USS 属性及其接受的值。
UIElements 样式属性使用与 W3C CSS 文档相同的语法句法:
auto
、baseline
。<
和 >
)之间。例如:<length>、<color>。<
和 >
)之间。例如,<border-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
次。width
和 height
指定元素的大小(以像素为单位)。如果未指定 width
,则宽度基于元素内容的宽度。如果未指定 height
,则高度基于元素内容的高度。
本节列出了用于定位视觉元素的属性。UIElements 包括一个布局引擎,可根据布局和样式属性定位视觉元素。该布局引擎实现了名为 Flexbox 的 HTML/CSS 布局系统的子集。
默认情况下,所有项都垂直放置在其容器中。
注意:由于不支持 units
,必须始终最后指定 <flex-basis>。
默认情况下,此属性设置为 relative
:根据父级来定位元素。如果此属性设置为 absolute
,则元素将保留其父级布局,并根据父级边界指定值。
相对于元素父级边缘或原始位置的像素距离。
绘制属性用于设置视觉元素的背景、边框和外观。
文本属性用于设置颜色、字体、字体大小以及 Unity 特有属性(字体资源、字形、对齐、自动换行和剪切)。
使用 cursor
默认纹理类型可为光标导入自定义纹理。Unity Editor 仅支持默认光标值。
cursor: [ [ <resource> | <url> ][ <hotspotX> <hotspotY>]? , ][ 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 ]
本节列出了在 UIElements 中已启用或更名的绘制属性。这些已弃用和更名的属性按字母顺序列出。
background-size
已更名为 -unity-background-scale-mode
。border-left
、border-top
、border-right
和 border-bottom
已分别更名为 border-left-width
、border-top-width
、border-right-width
和 border-bottom-width
。font
已更名为 -unity-font
。font-style
已更名为 -unity-font-style
。position-left
、position-top
、position-right
和 position-bottom
已分别更名为 left
、top
、right
和 bottom
。position-type
已更名为 position
。text-alignment
已更名为 -unity-text-align
。text-clipping
已更名为 -unity-clipping
。建议使用标准的 overflow
属性。text-color
已更名为 color
。-word-wrap
已更名为 -unity-word-wrap
。Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.