ui.Textbox.style

Trả về ActiveDictionary kiểu tiện ích. Bạn có thể sửa đổi ActiveDictionary này để cập nhật kiểu của tiện ích.

Các thuộc tính hoạt động giống như các thuộc tính CSS tương ứng:

  - height, maxHeight, minHeight (ví dụ: "100px")

  – width, maxWidth, minWidth (ví dụ: "100px")

  - khoảng đệm, lề (ví dụ: "4px 4px 4px 4px" hoặc đơn giản là "4px")

  – color, backgroundColor (ví dụ: "red" hoặc "#FF0000")

  – border (ví dụ: "1px solid black")

  - borderColor (ví dụ: "red black blue #FF0000")

  - borderRadius (ví dụ: "10px")

  – borderStyle (ví dụ: "solid dashed none dotted")

  - borderWidth (ví dụ: "1px 0px 1px 0px")

  - fontSize (ví dụ: "24px")

  - fontStyle (ví dụ: "italic")

  - fontWeight (ví dụ: "bold" hoặc "100")

  – fontFamily (ví dụ: "monospace" hoặc "serif")

  - textAlign (ví dụ: "left" hoặc "center")

  – textDecoration (ví dụ: "underline" hoặc "line-through")

  - whiteSpace (ví dụ: "nowrap" hoặc "pre")

  – shown (true hoặc false)

Các thuộc tính bố cục tuỳ chỉnh được hỗ trợ (xem tài liệu ui.Panel.Layout):

  – stretch ("horizontal", "vertical", "both")

  – vị trí ("top-right", "top-center", "top-left", "bottom-right", ...)

Cách sử dụngGiá trị trả về
Textbox.style()ui.data.ActiveDictionary
Đối sốLoạiThông tin chi tiết
this: ui.widgetui.WidgetЭкземпляр ui.Widget.

Ví dụ

Trình soạn thảo mã (JavaScript)

// Define a UI widget and add it to the map.
var widget = ui.Textbox({placeholder: 'Type here', 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', '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);