行为与 CSS 对应属性类似的属性:
- height、maxHeight、minHeight(例如“100px”)
- width、maxWidth、minWidth(例如“100px”)
- 内边距、外边距(例如“4px 4px 4px 4px”或简写为“4px”)
- color、backgroundColor(例如“red”或“#FF0000”)
- 边框(例如“1px solid black”)
- borderColor(例如:'red black blue #FF0000')
- borderRadius(例如“10px”)
- borderStyle(例如“实线 虚线 无 点划线”)
- borderWidth(例如“1px 0px 1px 0px”)
- fontSize(例如“24px”)
- fontStyle(例如“italic”)
- fontWeight(例如“bold”或“100”)
- fontFamily(例如“monospace”或“serif”)
- textAlign(例如“left”或“center”)
- textDecoration(例如“下划线”或“删除线”)
- whiteSpace(例如“nowrap”或“pre”)
- shown(true 或 false)
支持的自定义布局属性(请参阅 ui.Panel.Layout 文档):
- 拉伸(“horizontal”“vertical”“both”)
- 位置(“右上角”“顶部居中”“左上角”“右下角”等)
用法 | 返回 |
---|---|
Slider.style() | ui.data.ActiveDictionary |
参数 | 类型 | 详细信息 |
---|---|---|
此:ui.widget | ui.Widget | ui.Widget 实例。 |
示例
代码编辑器 (JavaScript)
// Define a UI widget and add it to the map. var widget = ui.Slider({style: {width: '400px'}}); Map.add(widget); // View the UI widget's style properties; an ActiveDictionary. print(widget.style()); // ActiveDictionaries are mutable; set a style property. widget.style().set('backgroundColor', 'E0E0E0'); print(widget.style()); // Define the UI widget's style ActiveDictionary as a variable. var widgetStyle = widget.style(); print(widgetStyle); // Set the UI widget's style properties from the ActiveDictionary variable. widgetStyle.set({border: '5px solid darkgray'}); print(widgetStyle);