ui.Panel.style

傳回小工具的樣式 ActiveDictionary,可修改以更新小工具的樣式。

與 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 (例如「solid dashed none dotted」)

  - borderWidth (例如「1px 0px 1px 0px」)

  - fontSize (例如「24px」)

  - fontStyle (例如「italic」)

  - fontWeight (例如「粗體」或「100」)

  - fontFamily (例如「monospace」或「serif」)

  - textAlign (例如「left」或「center」)

  - textDecoration (例如「underline」或「line-through」)

  - whiteSpace (例如「nowrap」或「pre」)

  - 顯示 (true 或 false)

支援的自訂版面配置屬性 (請參閱 ui.Panel.Layout 說明文件):

  - stretch ('horizontal', 'vertical', 'both')

  - 位置 ('top-right'、'top-center'、'top-left'、'bottom-right' 等)

用量傳回
Panel.style()ui.data.ActiveDictionary
引數類型詳細資料
this:ui.widgetui.Widgetui.Widget 例項。

範例

程式碼編輯器 (JavaScript)

// Define a UI widget and add it to the map.
var widget = ui.Panel({style: {width: '400px', height: '200px'}});
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', 'lightgray');
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);